Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Modelica/Electrical/Analog/Examples/OpAmps.mo
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ package OpAmps "Examples with operational amplifiers"
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimted opAmp1(
Vps=Vps,
Vns=Vns,
strict=false,
strict=true,
homotopyType=Modelica.Blocks.Types.LimiterHomotopy.UpperLimit)
annotation (Placement(transformation(extent={{-60,10},{-40,-10}})));
Modelica.Electrical.Analog.Basic.Resistor r2(R=R2, i(start=Vps/R2))
Expand All @@ -800,7 +800,7 @@ package OpAmps "Examples with operational amplifiers"
Vps=Vps,
Vns=Vns,
v_in(start=0),
strict=false)
strict=true)
annotation (Placement(transformation(extent={{30,-10},{50,10}})));
Modelica.Electrical.Analog.Basic.Capacitor c(C=C, v(fixed=true, start=0))
annotation (Placement(transformation(extent={{50,20},{30,40}})));
Expand Down
48 changes: 31 additions & 17 deletions Modelica/Fluid/Dissipation.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4530,37 +4530,42 @@ This record is used as <strong> input record </strong> for the pressure loss fun
output SI.Pressure DP "Output for function dp_volumeFlowRate_DP";

protected
Real a=max(Modelica.Constants.eps, abs(IN_con.a));
Real b=max(Modelica.Constants.eps, abs(IN_con.b));
Real a=abs(IN_con.a);
Real b=abs(IN_con.b);

SI.VolumeFlowRate V_flow=m_flow/max(Modelica.Constants.eps, IN_var.rho)
"Volume flow rate";
SI.Pressure dp_min=IN_con.dp_min
SI.Pressure dp_min=max(Modelica.Constants.eps, abs(IN_con.dp_min))
"Start of approximation for decreasing pressure loss";
SI.VolumeFlowRate V_flow_smooth=if IN_con.a > 0 then -(b/(2*a) + ((-b/(2*a))^
2 + dp_min/a)^0.5) else dp_min/b
SI.VolumeFlowRate V_flow_smooth=if a > 0 and b <= 0 then (dp_min/a)^0.5 else 0
"Start of approximation for decreasing volume flow rate";

//Documentation

algorithm
DP := a*Dissipation.Utilities.Functions.General.SmoothPower(
assert(a+b>0, "Please provide non-zero factors for either a or b of function dp=a*V_flow^2 + b*V_flow");

// Please note the function is reqularized for zero flow with the parameter b if b>0.

DP := a*(if a>0 and b<=0 then Dissipation.Utilities.Functions.General.SmoothPower(
V_flow,
V_flow_smooth,
2) + b*V_flow;
2) elseif a>0 and b>0 then V_flow*abs(V_flow) else 0) + b*V_flow;
annotation (Inline=false, smoothOrder(normallyConstant=IN_con) = 2,
inverse(m_flow=Modelica.Fluid.Dissipation.PressureLoss.General.dp_volumeFlowRate_MFLOW(
IN_con,
IN_var,
DP)), Documentation(info="<html>
<p>
Calculation of a generic pressure loss with linear or quadratic dependence on volume flow rate.
Calculation of a generic pressure loss with linear and/or quadratic dependence on volume flow rate. <strong>Please note that the sum of a and b has to be greater zero</strong>.
The function can be used to calculate pressure loss at known mass flow rate <strong> or </strong> mass flow rate at known pressure loss.
</p>

<p>
Generally this function is numerically best used for the <strong> incompressible case </strong>, where the mass flow rate (m_flow) is known (as state variable) in the used model and the corresponding pressure loss (DP) has to be calculated. On the other hand the function <a href=\"modelica://Modelica.Fluid.Dissipation.PressureLoss.General.dp_volumeFlowRate_MFLOW\">dp_volumeFlowRate_MFLOW</a> is numerically best used for the <strong> compressible case </strong> if the pressure loss (dp) is known (out of pressures as state variable) and the mass flow rate (M_FLOW) has to be calculated. <a href=\"modelica://Modelica.Fluid.Dissipation.Utilities.SharedDocumentation.PressureLoss.General.dp_volumeFlowRate\">See more information</a>.
</p>
</html>", revisions="<html>
2018-11-21 Stefan Wischhusen: Fixed problem for linear case (a=0 and b>0) and obsolete regularization for a>0 and b>0.
</html>"));
end dp_volumeFlowRate_DP;

Expand All @@ -4586,33 +4591,42 @@ Generally this function is numerically best used for the <strong> incompressibl
"Output for function dp_volumeFlowRate_MFLOW";

protected
Real a=max(Modelica.Constants.eps, abs(IN_con.a));
Real b=max(Modelica.Constants.eps, abs(IN_con.b));
Real a=abs(IN_con.a);
Real b=abs(IN_con.b);

SI.Pressure dp_min=IN_con.dp_min
SI.Pressure dp_min=max(Modelica.Constants.eps, abs(IN_con.dp_min))
"Start of approximation for decreasing pressure loss";

//Documentation

algorithm
M_FLOW := IN_var.rho*(-b/(2*a) +
assert(a+b>0, "Please provide non-zero factors for either a or b of function dp=a*V_flow^2 + b*V_flow");

// Please note the function is reqularized for zero flow with the parameter b if b>0.

M_FLOW := IN_var.rho*(if a>0 and b<=0 then
Modelica.Fluid.Dissipation.Utilities.Functions.General.SmoothPower(
(b/(2*a))^2 + (1/a)*dp,
(b/(2*a))^2 + (1/a)*dp_min,
0.5));
(1/a)*dp,
(1/a)*dp_min,
0.5)
elseif a>0 and b>0 then
sign(dp)*(-b/(2*a) + sqrt((b/(2*a))^2 + (1/a)*abs(dp)))
else b*dp);
annotation (Inline=true, smoothOrder(normallyConstant=IN_con) = 2,
inverse(dp=Modelica.Fluid.Dissipation.PressureLoss.General.dp_volumeFlowRate_DP(
IN_con,
IN_var,
M_FLOW)), Documentation(info="<html>
<p>
Calculation of a generic pressure loss with linear or quadratic dependence on volume flow rate.
Calculation of a generic pressure loss with linear or quadratic dependence on volume flow rate. <strong>Please note that the sum of a and b has to be greater zero</strong>.
The function can be used to calculate pressure loss at known mass flow rate <strong> or </strong> mass flow rate at known pressure loss.
</p>

<p>
Generally this function is numerically best used for the <strong> compressible case </strong> if the pressure loss (dp) is known (out of pressures as state variable) and the mass flow rate (M_FLOW) has to be calculated. On the other hand the function <a href=\"modelica://Modelica.Fluid.Dissipation.PressureLoss.General.dp_volumeFlowRate_DP\">dp_volumeFlowRate_DP</a> is numerically best used for the <strong> incompressible case </strong>, where the mass flow rate (m_flow) is known (as state variable) in the used model and the corresponding pressure loss (DP) has to be calculated. <a href=\"modelica://Modelica.Fluid.Dissipation.Utilities.SharedDocumentation.PressureLoss.General.dp_volumeFlowRate\">See more information</a>.
</p>
</html>", revisions="<html>
2018-11-21 Stefan Wischhusen: Fixed problem for linear case (a=0 and b>0) and obsolete regularization for a>0 and b>0.
</html>"));
end dp_volumeFlowRate_MFLOW;

Expand All @@ -4624,7 +4638,7 @@ Generally this function is numerically best used for the <strong> compressible
Modelica.Fluid.Dissipation.Utilities.Records.General.QuadraticVFLOW;

SI.Pressure dp_min=0.1
"Start of approximation for decreasing pressure loss";
"Start of approximation for decreasing pressure loss (only used for b=0)";

annotation (Documentation(info="<html>
This record is used as <strong> input record </strong> for the pressure loss function
Expand Down
16 changes: 11 additions & 5 deletions Modelica/Magnetic/FluxTubes.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2709,7 +2709,7 @@ The differences between these two models in static behaviour can be analysed and
5,500; 6,-24; 7,24; 8,-24; 9,24; 10,-24; 11,24; 12,-24; 13,24; 14,
-24; 15,24])
annotation (Placement(transformation(extent={{-90,50},{-70,70}})));
Basic.ElectroMagneticConverterWithLeakageInductance winding1(N=1) "Winding 1" annotation (Placement(transformation(extent={{30,50},{50,70}})));
Basic.ElectroMagneticConverterWithLeakageInductance winding1(i(start=0, fixed=true), N=1) "Winding 1" annotation (Placement(transformation(extent={{30,50},{50,70}})));
Modelica.Electrical.Analog.Basic.Ground elGnd1
annotation (Placement(transformation(extent={{0,30},{20,50}})));
Basic.Ground magGnd1
Expand All @@ -2719,7 +2719,7 @@ The differences between these two models in static behaviour can be analysed and
extent={{10,-10},{-10,10}},
rotation=90,
origin={-10,60})));
Basic.ElectroMagneticConverterWithLeakageInductance winding2(N=1) "Winding 2" annotation (Placement(transformation(extent={{30,-10},{50,10}})));
Basic.ElectroMagneticConverterWithLeakageInductance winding2(i(start=0, fixed=true), N=1) "Winding 2" annotation (Placement(transformation(extent={{30,-10},{50,10}})));
Modelica.Electrical.Analog.Basic.Ground elGnd2
annotation (Placement(transformation(extent={{0,-30},{20,-10}})));
Shapes.HysteresisAndMagnets.GenericHystTellinenTable tellinenTable(
Expand All @@ -2739,7 +2739,7 @@ The differences between these two models in static behaviour can be analysed and
extent={{10,-10},{-10,10}},
rotation=90,
origin={-10,0})));
Basic.ElectroMagneticConverterWithLeakageInductance winding3(N=1) "Winding 3" annotation (Placement(transformation(extent={{30,-70},{50,-50}})));
Basic.ElectroMagneticConverterWithLeakageInductance winding3(i(fixed=true, start=0), N=1) "Winding 3" annotation (Placement(transformation(extent={{30,-70},{50,-50}})));
Modelica.Electrical.Analog.Basic.Ground elGnd3
annotation (Placement(transformation(extent={{0,-90},{20,-70}})));
Shapes.HysteresisAndMagnets.GenericHystPreisachEverett preisachEverett(
Expand Down Expand Up @@ -2908,6 +2908,8 @@ This is a simple model of an inductor with a ferromagnetic core. The used Generi
A=5e-4,
MagRel(start=0.5, fixed=true))
annotation (Placement(transformation(extent={{-10,10},{10,30}})));
initial equation
core.derHstat = 0.0;
equation
connect(winding1.port_n, mag_ground.port) annotation (Line(points={{-20,-10},{-20,-20},{0,-20}}, color={255,127,0}));
connect(vSource.p, resistor1.p) annotation (Line(points={{-80,10},{-80,20},{-70,20}}, color={0,0,255}));
Expand Down Expand Up @@ -2971,6 +2973,8 @@ Then plot the flux density of the Core Core.B over the magnetic field strength C
I1Fixed=true,
EddyCurrents=false,
HFixed=false) annotation (Placement(transformation(extent={{-10,10},{10,30}})));
initial equation
transformer.core.derHstat = 0.0;
equation
connect(SineVoltage.p, resistor1.p) annotation (Line(points={{-60,30},{-60,40},{-50,40}}, color={0,0,255}));
connect(SineVoltage.n, el_ground1.p) annotation (Line(points={{-60,10},{-60,0},{-40,0}},color={0,0,255}));
Expand Down Expand Up @@ -3108,6 +3112,10 @@ The figure shows the magnetic hysteresis in the transformer core. In (a) the con
Modelica.Blocks.Continuous.Filter pdissCopAvg(f_cut=10)
"Approx. average copper losses"
annotation (Placement(transformation(extent={{-50,40},{-40,50}})));
initial equation
transformer.core1.derHstat = 0.0;
transformer.core2.derHstat = 0.0;
transformer.core3.derHstat = 0.0;
equation
connect(vSource1.n, ground1.p) annotation (Line(points={{-140,-50},{-140,-70},{-110,-70}}, color={0,0,255}));
connect(vSource2.n, ground1.p) annotation (Line(points={{-120,-50},{-120,-70},{-110,-70}}, color={0,0,255}));
Expand Down Expand Up @@ -3521,7 +3529,6 @@ Simple model of a single phase transformer with a primary and a secondary windin
parameter Real mu_rel2=1
"Constant relative permeability of secondary leakage (>0 required)" annotation (Dialog(tab="Leakage"));

protected
Shapes.HysteresisAndMagnets.GenericHystTellinenEverett core1(
mat=mat,
A=a*b,
Expand Down Expand Up @@ -3650,7 +3657,6 @@ Simple model of a single phase transformer with a primary and a secondary windin
rotation=270,
origin={32,90})));

public
Modelica.Electrical.Analog.Interfaces.PositivePin p1 "Primary winding 1" annotation (Placement(transformation(extent={{-170,50},{-150,70}}), iconTransformation(extent={{-110,50},{-90,70}})));
Modelica.Electrical.Analog.Interfaces.PositivePin p2 "Primary winding 2" annotation (Placement(transformation(extent={{-70,50},{-50,70}}), iconTransformation(extent={{-110,-10},{-90,10}})));
Modelica.Electrical.Analog.Interfaces.PositivePin p3 "Primary winding 3" annotation (Placement(transformation(extent={{50,50},{70,70}}), iconTransformation(extent={{-110,-70},{-90,-50}})));
Expand Down