Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #576 by replacing internal models by one utility model #2533

Merged
merged 3 commits into from
May 18, 2018

Conversation

dietmarw
Copy link
Member

@dietmarw dietmarw commented May 16, 2018

Instead of having the no-accessible models rn and rp inside the example I've created one universally usable switched capacitor model instead.

Note: When replacing rn and rp in Modelica.Electrical.Analog.Examples.CauerLowPassSC I noticed that this and the other examples are in dire need of an clean up since the coding style is sub fortunate (lots of unnecessary protected connectors with no real purpose).

Close #576.

Instead of having the no-accessible models `rn` and `rp` inside the example I've created **one**  universally usable switched capacitor model instead. 

Note: When replacing `rn` and `rp` in `Modelica.Electrical.Analog.Examples.CauerLowPassSC` I noticed that this and the other examples are in dire need of an clean up since the coding style is sub fortunate (lots of unnecessary protected connectors with no real purpose).
@dietmarw dietmarw added the L: Electrical.Analog Issue addresses Modelica.Electrical.Analog label May 16, 2018
@beutlich beutlich added this to the MSL3.2.3 milestone May 16, 2018
parameter Modelica.SIunits.Time clock=1 "Clock";
parameter Modelica.SIunits.Resistance R=1 "Resistance";
Modelica.Blocks.Sources.BooleanPulse BooleanPulse(period=clock) annotation (Placement(transformation(extent={{-8,70},{12,90}})));
Modelica.Electrical.Analog.Basic.Capacitor Capacitor(C=clock/max(Modelica.Constants.eps,abs(R)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this pass the unit check?

Copy link
Member Author

@dietmarw dietmarw May 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the unit is correctly derived both in Dymola and in OpenModelica though it really depends on how the max function works.
@HansOlsson, @sjoelund is that somehow specified?
I can always make it 100% sure by changing it to:

Modelica.Electrical.Analog.Basic.Capacitor Capacitor(C=clock/max(minR,abs(R)))
protected
constant Modelica.SIunits.Resistance minR = Modelica.Constants.eps "Helping constant for division by zero protection";

but I think it might be overdoing it especially when it is not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've decided to implement it using a "oneOhm" helping constant. So this should now be bullet proof. I'm still interested in the general question if this would be necessary really.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact unit-handling involving such cases is not yet fully standardized, and I will have to go through the details of the proposed MCP - but such cases should be handled.

Another solution is to just skip the guard - and just accept that bad parameter values lead to division by zero, the old models did not handle small resistances either (the difference was that it was specified using min-value - but here we want R to avoid a region around zero - which cannot be represented with min/max attribute).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to keep the guard as I see this as an improvement so that should people end up using the new component don't end up with some error message just because of a 0 resistance. I hope that is acceptable for you.

Copy link
Contributor

@HansOlsson HansOlsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good.

But I think the R in SwitchedCapacitor should only have R(start=1) - and the old Rp components have R=1 to make it more "symmetric".

Possibly similarly for the clock-parameter (all components already modify it).

@dietmarw
Copy link
Member Author

I agree that the default values should be given as start and also that the example should then have all instances parameterised in order to not trigger the warning. I hope this is now good to go.

@beutlich beutlich merged commit e41a9e2 into modelica:master May 18, 2018
@beutlich beutlich removed the request for review from kristinmajetta May 18, 2018 07:04
@beutlich beutlich self-assigned this May 18, 2018
@dietmarw dietmarw deleted the ticket576-removeRnRp branch May 18, 2018 10:08
@beutlich beutlich added enhancement New feature or enhancement example Issue only addresses example(s) labels May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement example Issue only addresses example(s) L: Electrical.Analog Issue addresses Modelica.Electrical.Analog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants