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

Add defaults for Valve params and assert for check #201

Merged
merged 8 commits into from
Jul 23, 2024

Conversation

dzimmer
Copy link
Contributor

@dzimmer dzimmer commented Jul 11, 2024

closes #171 according to result of the discussion

substitutes #187

Performed regression test succesfully.

@@ -31,6 +31,18 @@ protected
else m_flow_ref_set/rho_ref "Reference volume flow";

equation

//this if clause shall ensure that valid parameters have been entered
if flowCoefficient == FlowCoeffType.Kvs then
Copy link

@bilderbuchi bilderbuchi Jul 12, 2024

Choose a reason for hiding this comment

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

@dzimmer @casella Considering only parameters are involved here, wouldn't it be better/more efficient/performant to place these if statements in an initial equation section, so they are only evaluated once instead of continuously?
Or can it be expected (is it specified, maybe?) that tools optimize that out and only execute it once, anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that Dymola will optimize for it but the specification does not say anything about it.
Moving to initial equations seems like a good idea.

Copy link
Contributor

@tobolar tobolar Jul 17, 2024

Choose a reason for hiding this comment

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

Actually, the assertion level is set to "error". So the current model's evaluation shall be aborted. The simulation itself still may continue with another evaluation, but IMO is not the case here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stupid me... Of course that is why I did not care when implementing it.

Choose a reason for hiding this comment

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

Huh? It will only abort if the assert fails, no? If not, does this not check if Kvs>0 over and over again?

Copy link

@bilderbuchi bilderbuchi Jul 18, 2024

Choose a reason for hiding this comment

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

Meaning, if you have FlowCoeffType.Kvs, and a Kvs of, say, 0.1, you would still trigger an assert check at every time step?

Copy link
Contributor

Choose a reason for hiding this comment

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

At least there is a Modelica example with assert() for parameters.
https://build.openmodelica.org/Documentation/ModelicaReference.Operators.%27assert()%27.html

and assert for parameters is used e.g. in:

  • Modelica.Blocks.Continuous.Filter
  • Modelica.Electrical.Analog.Semiconductors.Diode2
  • Modelica.Fluid.Pipes.BaseClasses.PartialStraightPipe
  • Modelica.Mechanics.MultiBody.Joints.Revolute

I can't tell how often the assert is evaluated tho.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • corrected some typos
  • changed V_flow_ref to final parameter V_flow_ref
  • added a default value + assert for d_valve (ThermofluidStream.FlowControl.SpecificValveType).

I didnt know how to suggest the changes, i hope its fine, that i directly pushed them.

Could we also change m_flow_ref in ThermofluidStream.FlowControl.Internal.PartialValve to parameter m_flow_ref, or does that cause issues concerning conversion script or so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushing directly is the best way.
I'll move the assert to the initial and if I do not find any reason against it would change m_flow_ref to a parameter

@tobolar tobolar changed the title Added defaults for Valve params and assert for check Add defaults for Valve params and assert for check Jul 17, 2024
@dzimmer
Copy link
Contributor Author

dzimmer commented Jul 22, 2024

  • Performed the work described above.

  • To transform m_flow_ref into a parameter, I had to use (fixed=false) attribute and move the corresponding equation into the initial section. This should be 100% legal Modelica. I hope it works for the other tools but it should.

  • Performed regression test. All results good. Feel free to merge.

@RaphaelGebhart RaphaelGebhart merged commit e0a3387 into DLR-SR:main Jul 23, 2024
4 checks passed
nieweber pushed a commit that referenced this pull request Aug 2, 2024
* Added defaults for Valve params and assert for check

* Omit SI-units in description of parameter m_flow_ref_set

* Typos

* Changed V_flow_ref to final parameter

* Added default value + assert for d_valve (ThermofluidStream.FlowControl.SpecificValveType)

* Same for TFS.Undirected

* assert to initial equations

* turned m_flow_ref into parameter

---------

Co-authored-by: tobolar <[email protected]>
Co-authored-by: Raphael Gebhart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants