diff --git a/Modelica/Electrical/Analog/Examples/OpAmps.mo b/Modelica/Electrical/Analog/Examples/OpAmps.mo index a4beb6ab78..72f4b28b6a 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps.mo @@ -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)) @@ -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}}))); diff --git a/Modelica/Fluid/Dissipation.mo b/Modelica/Fluid/Dissipation.mo index 1fb89c429c..bea1658ad7 100644 --- a/Modelica/Fluid/Dissipation.mo +++ b/Modelica/Fluid/Dissipation.mo @@ -4530,37 +4530,42 @@ This record is used as input record 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="

-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. Please note that the sum of a and b has to be greater zero. The function can be used to calculate pressure loss at known mass flow rate or mass flow rate at known pressure loss.

Generally this function is numerically best used for the incompressible case , 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 dp_volumeFlowRate_MFLOW is numerically best used for the compressible case if the pressure loss (dp) is known (out of pressures as state variable) and the mass flow rate (M_FLOW) has to be calculated. See more information.

+", revisions=" +2018-11-21 Stefan Wischhusen: Fixed problem for linear case (a=0 and b>0) and obsolete regularization for a>0 and b>0. ")); end dp_volumeFlowRate_DP; @@ -4586,33 +4591,42 @@ Generally this function is numerically best used for the 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="

-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. Please note that the sum of a and b has to be greater zero. The function can be used to calculate pressure loss at known mass flow rate or mass flow rate at known pressure loss.

Generally this function is numerically best used for the compressible case 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 dp_volumeFlowRate_DP is numerically best used for the incompressible case , 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. See more information.

+", revisions=" +2018-11-21 Stefan Wischhusen: Fixed problem for linear case (a=0 and b>0) and obsolete regularization for a>0 and b>0. ")); end dp_volumeFlowRate_MFLOW; @@ -4624,7 +4638,7 @@ Generally this function is numerically best used for the 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=" This record is used as input record for the pressure loss function diff --git a/Modelica/Magnetic/FluxTubes.mo b/Modelica/Magnetic/FluxTubes.mo index 005235e749..78637fab07 100644 --- a/Modelica/Magnetic/FluxTubes.mo +++ b/Modelica/Magnetic/FluxTubes.mo @@ -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 @@ -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( @@ -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( @@ -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})); @@ -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})); @@ -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})); @@ -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, @@ -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}})));