Repository navigation
Fix unit inconsistencies caused by 'pi' carrying a unit #4817
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4484,7 +4484,7 @@ | |
| extends Modelica.Icons.Record; | ||
|
|
||
| //generic variables | ||
| SI.Area A_cross=Modelica.Constants.pi*0.1^2/4 "Cross sectional area" | ||
| SI.Area A_cross=Modelica.Constants.pi*(0.1'm')^2/4 "Cross sectional area" | ||
| annotation (Dialog(group="Generic variables")); | ||
|
|
||
| //linearisation | ||
|
|
@@ -10049,9 +10049,9 @@ | |
| annotation (Dialog(group="Choices")); | ||
|
|
||
| //geometry | ||
| input SI.Area A_cross(min=Modelica.Constants.eps) = PI*0.1^2/4 | ||
| input SI.Area A_cross(min=Modelica.Constants.eps) = PI*(0.1'm')^2/4 | ||
| "Cross sectional area" annotation (Dialog(group="Geometry")); | ||
| input SI.Length perimeter(min=Modelica.Constants.eps) = PI*0.1 | ||
| input SI.Length perimeter(min=Modelica.Constants.eps) = PI*0.1'm' | ||
|
Comment on lines
-10052
to
+10054
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also indicates that the classes aren't well-designed. Both the cross area and perimeter have defaults based on the diameter being 0.1'm', but instead of having one default depending on the other input (or on a common diameter input), the default diameter is duplicated in this function and related ones (it can only be a default as the goal is to support non-circular cross-sections). That makes it more error-prone. It would be possible to introduce a backwards compatible change for that by having a new trailing diameter-input that only impacts the defaults. The down-side is that existing calls wouldn't modify the default-diameter and that value would be a bit confusing. Alternatively, it would also be possible to have the default for the cross-section depend on the perimeter ( (Note that it uses the general term "perimeter", not "circumference".) |
||
| "Perimeter" | ||
| annotation (Dialog(group="Geometry")); | ||
|
|
||
|
|
@@ -12511,7 +12511,7 @@ | |
|
|
||
| SI.Area A_cross=A_cross_nom "Cross sectional area" | ||
| annotation (Dialog(group="Generic variables")); | ||
| SI.Area A_cross_nom=Modelica.Constants.pi*0.1^2/4 | ||
| SI.Area A_cross_nom=Modelica.Constants.pi*(0.1'm')^2/4 | ||
| "Nominal cross sectional area" | ||
| annotation (Dialog(group="Generic variables")); | ||
|
|
||
|
|
@@ -12564,9 +12564,9 @@ | |
| record TwoPhaseFlow_con "Base record for two phase Flow" | ||
| extends Modelica.Icons.Record; | ||
|
|
||
| SI.Area A_cross=PI*0.1^2/4 "Cross sectional area" | ||
| SI.Area A_cross=PI*(0.1'm')^2/4 "Cross sectional area" | ||
| annotation (Dialog(group="Geometry")); | ||
| SI.Length perimeter=PI*0.1 "Wetted perimeter" | ||
| SI.Length perimeter=PI*0.1'm' "Wetted perimeter" | ||
| annotation (Dialog(group="Geometry")); | ||
| SI.Length length=1 "Length in fluid flow direction" | ||
| annotation (Dialog(group="Geometry")); | ||
|
|
@@ -12628,7 +12628,7 @@ | |
|
|
||
| parameter SI.Area A_cross=A_cross_nom "Cross sectional area" | ||
| annotation (Dialog(group="Generic variables")); | ||
| parameter SI.Area A_cross_nom=Modelica.Constants.pi*0.1^2/4 | ||
| parameter SI.Area A_cross_nom=Modelica.Constants.pi*(0.1'm')^2/4 | ||
| "Nominal cross sectional area" | ||
| annotation (Dialog(group="Generic variables")); | ||
|
|
||
|
|
@@ -12704,9 +12704,9 @@ | |
| "Target correlation" annotation (Dialog(group="Generic variables")); | ||
|
|
||
| //geometry | ||
| SI.Area A_cross=Modelica.Constants.pi*0.1^2/4 "Cross sectional area" | ||
| SI.Area A_cross=Modelica.Constants.pi*(0.1'm')^2/4 "Cross sectional area" | ||
| annotation (Dialog(group="Generic variables")); | ||
| SI.Length perimeter=Modelica.Constants.pi*0.1 "Wetted perimeter" | ||
| SI.Length perimeter=Modelica.Constants.pi*0.1'm' "Wetted perimeter" | ||
| annotation (Dialog(group="Generic variables")); | ||
| end General; | ||
|
|
||
|
|
@@ -12749,9 +12749,9 @@ | |
| "Choice of (horizontal/vertical) boiling or (horizontal) condensation in pipe" | ||
| annotation (Dialog(group="Choices")); | ||
|
|
||
| SI.Area A_cross=Modelica.Constants.pi*0.1^2/4 "Cross sectional area" | ||
| SI.Area A_cross=Modelica.Constants.pi*(0.1'm')^2/4 "Cross sectional area" | ||
| annotation (Dialog(group="Geometry")); | ||
| SI.Length perimeter=Modelica.Constants.pi*0.1 "Wetted perimeter" | ||
| SI.Length perimeter=Modelica.Constants.pi*0.1'm' "Wetted perimeter" | ||
| annotation (Dialog(group="Geometry")); | ||
|
|
||
| Modelica.Fluid.Dissipation.Utilities.Types.MolarMass_gpmol MM=18.02 | ||
|
|
@@ -12884,9 +12884,9 @@ | |
| annotation (Dialog(group="Orifice")); | ||
| SI.Length C_0=0.1*C_1 "Perimeter of vena contraction" | ||
| annotation (Dialog(group="Orifice")); | ||
| SI.Area A_1=PI*0.01^2/4 "Large cross sectional area of orifice" | ||
| SI.Area A_1=PI*(0.01'm')^2/4 "Large cross sectional area of orifice" | ||
| annotation (Dialog(group="Orifice")); | ||
| SI.Length C_1=PI*0.01 "Large perimeter of orifice" | ||
| SI.Length C_1=PI*0.01'm' "Large perimeter of orifice" | ||
| annotation (Dialog(group="Orifice")); | ||
| SI.Length L=1e-3 "Length of vena contraction" | ||
| annotation (Dialog(group="Orifice")); | ||
|
|
@@ -12949,13 +12949,13 @@ | |
| SI.Angle alpha=PI*45/180 "Diffuser diverging angle" | ||
| annotation (Dialog(group="Diffuser")); | ||
|
|
||
| SI.Area A_1=PI*0.01^2/4 | ||
| SI.Area A_1=PI*(0.01'm')^2/4 | ||
| "Small constant cross sectional area before diffuser section" | ||
| annotation (Dialog(group="Diffuser")); | ||
| SI.Area A_2=2*A_1 | ||
| "Large constant cross sectional area after diffuser section" | ||
| annotation (Dialog(group="Diffuser")); | ||
| SI.Length C_1=PI*0.01 "Small perimeter before diffuser section" | ||
| SI.Length C_1=PI*0.01'm' "Small perimeter before diffuser section" | ||
| annotation (Dialog(group="Diffuser")); | ||
| SI.Length C_2=2*C_1 "Large perimeter after diffuser section" | ||
| annotation (Dialog(group="Diffuser")); | ||
|
|
@@ -12995,11 +12995,11 @@ | |
|
|
||
| extends Modelica.Icons.Record; | ||
|
|
||
| SI.Area A_1=PI*0.01^2/4 "Small cross sectional area of orifice" | ||
| SI.Area A_1=PI*(0.01'm')^2/4 "Small cross sectional area of orifice" | ||
| annotation (Dialog(group="Orifice")); | ||
| SI.Area A_2=A_1 "Large cross sectional area of orifice" | ||
| annotation (Dialog(group="Orifice")); | ||
| SI.Length C_1=PI*0.01 "Small perimeter of orifice" | ||
| SI.Length C_1=PI*0.01'm' "Small perimeter of orifice" | ||
| annotation (Dialog(group="Orifice")); | ||
| SI.Length C_2=C_1 "Large perimeter of orifice" | ||
| annotation (Dialog(group="Orifice")); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ | |
| offset=1, | ||
| startTime=startTime) annotation (Placement(transformation(extent={{-160, | ||
| -30},{-140,-10}}))); | ||
| Modelica.Blocks.Sources.Sine sine(amplitude=200, f=50/pi) | ||
| Modelica.Blocks.Sources.Sine sine(amplitude=200, f=50'Hz'/pi) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be careful with Hertz (just a note on this, but all need to be checked). Despite being defined as In this case it seems like a complete mess and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The unit of |
||
| annotation (Placement(transformation(extent={{-160,10},{-140,30}}))); | ||
| Modelica.Blocks.Math.Product product annotation (Placement(transformation( | ||
| extent={{-120,-10},{-100,10}}))); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,8 +29,8 @@ package SinglePhase "Single-phase quasi-static package" | |||||||||||||||||
| origin={40,-40}))); | ||||||||||||||||||
| Modelica.Blocks.Sources.Constant const(k=1) annotation (Placement(transformation(extent={{-50,50},{-30,70}}))); | ||||||||||||||||||
| Modelica.Blocks.Sources.Constant const1(k=1) annotation (Placement(transformation(extent={{-20,70},{0,90}}))); | ||||||||||||||||||
| Modelica.Blocks.Sources.Constant const2(k=1/100/Modelica.Constants.pi) annotation (Placement(transformation(extent={{70,70},{50,90}}))); | ||||||||||||||||||
| Modelica.Blocks.Sources.Constant const3(k=1/100/Modelica.Constants.pi) annotation (Placement(transformation(extent={{100,50},{80,70}}))); | ||||||||||||||||||
| Modelica.Blocks.Sources.Constant const2(k=1'F'/100/Modelica.Constants.pi) annotation (Placement(transformation(extent={{70,70},{50,90}}))); | ||||||||||||||||||
| Modelica.Blocks.Sources.Constant const3(k=1'H'/100/Modelica.Constants.pi) annotation (Placement(transformation(extent={{100,50},{80,70}}))); | ||||||||||||||||||
|
Comment on lines
+32
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this needs to be considered more, the 100*pi is 50'Hz'2pi, where 50 Hertz is the normal frequency in Europe.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where the constants are used: Here, That's as far as the units go. Regarding how to express the value, would you prefer this?
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is one possibility, the other would be something like:
Suggested change
I could see some explanation along those lines based on resonance circuits etc, but I don't have the domain knowledge to judge whether people normally write (and/or understand) formulas like that or not.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #4774 (comment) gave a more readable solution
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the suggestion is simply to introduce new parameters instead of the unitful literals? If this is what everyone wants, I'll do it that way. @AHaumer ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear it is new parameters revealing the logic of the model, as indicated in that comment.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the suggestion in "that comment" is missing some use of Or should some of { ( |
||||||||||||||||||
| Modelica.ComplexBlocks.Sources.ComplexConstant const4(k(re=0.5, im=0.5)) annotation (Placement(transformation(extent={{0,-70},{20,-50}}))); | ||||||||||||||||||
| Modelica.ComplexBlocks.Sources.ComplexConstant const5(k(re=1, im=1)) annotation (Placement(transformation(extent={{-30,-90},{-10,-70}}))); | ||||||||||||||||||
| Modelica.Electrical.QuasiStatic.SinglePhase.Sensors.VoltageSensor voltageSensor annotation (Placement(transformation( | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those changes disclose another dilemma that moparser fron deprecated repository https://github.com/modelica-tools/ModelicaSyntaxChecker is still used here while no adequate replacement is in sight or in-place. Therefore we need to address this CI issue beforehand -> #4821.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #4774 (comment) for a better alternative for this model