Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » Getudan
  • » Profile

Posts

Posts

Jan-15-20 01:12:41
Resting Time to Zero at a Switching Voltage

YOU ARE THE MAN!!
I don't know how I can thank you!!!

Beer?

Jan-14-20 18:42:53
Resting Time to Zero at a Switching Voltage

Please bear with me, the shame!
How do I declare LTime as Boolean?

Jan-14-20 18:39:28
Resting Time to Zero at a Switching Voltage

How should I declare LTime?
Would the below work?
type LTime = Real(unit = "Sec");

Jan-14-20 16:28:03
Resting Time to Zero at a Switching Voltage

Thanks for your response!

The idea was to represent an out put of a Boolean true value with u. Do you any idea on how to get/use an out put of a Boolean value?

Thanks again!

Jan-13-20 16:01:32
Resting Time to Zero at a Switching Voltage

HI,
I am using the attached simple RLC circuit with a time dependent inductance.

I am trying to get the time (LTime) start from zero at each switching point of the voltage for the inductance.  It is clear that I don't know what I am doing looking at lines 36 to 45 of the attachment.

How do I use a "booleanPulse" value as a trigger to set an event, in this case to reset the time = 0 for the time dependent inductance at the end of each period?

Any help would be appreciated.

Thanks!

Code:

model Test3

  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  import Modelica.Math.sin;
  type Time1 = Real(unit = "Sec");
  type Frequency = Real(unit = "Hz");
  type Inductance = Real(unit = "H");
  type FResonant = Real(unit = "HZ");
  type Period1 = Real(unit = "Sec");
  input Boolean u = true;
  input Real LTime;
  parameter Modelica.SIunits.Resistance R = 20 "Resistance";
  parameter Modelica.SIunits.Inductance L0 = 0.004 "Inductance";
  parameter Modelica.SIunits.Capacitance C = 1e-12 "Capacitance";
  parameter Modelica.SIunits.Voltage V = 50 "DC Voltage";
  parameter Time1 T1 = 1e-6;
  parameter Frequency w2 = 2 * pi * 2e6;
  parameter FResonant Fr = 1 / (2 * pi * sqrt(L0 * C));
  Modelica.Electrical.Analog.Basic.Ground ground annotation(
    Placement(visible = true, transformation(origin = {-70, -66}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Capacitor capacitor(C = C) annotation(
    Placement(visible = true, transformation(origin = {30, -24}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Analog.Basic.Resistor resistor(R = R) annotation(
    Placement(visible = true, transformation(origin = {30, 60}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  //Inductance L;
  Modelica.Electrical.Analog.Ideal.IdealCommutingSwitch switch annotation(
    Placement(visible = true, transformation(origin = {-42, 74}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V = 5) annotation(
    Placement(visible = true, transformation(origin = {-78, 14}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Blocks.Sources.BooleanPulse booleanPulse(period = 24.579e-6, startTime = 0, width = 50) annotation(
    Placement(visible = true, transformation(origin = {-46, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Sources.RealExpression realExpression(y = L0 * (1 - exp(-LTime / T1) * sin(w2 * LTime))) annotation(
    Placement(visible = true, transformation(origin = {68, 24}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.VariableInductor inductor annotation(
    Placement(visible = true, transformation(origin = {30, 24}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
protected
  discrete Modelica.SIunits.Time entryTime "Time instant when u became true";
initial equation
  pre(entryTime) = 0;
equation
  when true then
    LTime = time;
  end when;
  LTime = if u then time - LTime
  else 0.0;
 
  connect(capacitor.n, ground.p) annotation(
    Line(points = {{30, -34}, {-20, -34}, {-20, -56}, {-70, -56}}, color = {0, 0, 255}));
  connect(switch.p, resistor.p) annotation(
    Line(points = {{-32, 74}, {30, 74}, {30, 70}}, color = {0, 0, 255}));
  connect(constantVoltage.n, ground.p) annotation(
    Line(points = {{-78, 4}, {-70, 4}, {-70, -56}}, color = {0, 0, 255}));
  connect(constantVoltage.p, switch.n1) annotation(
    Line(points = {{-78, 24}, {-74, 24}, {-74, 70}, {-52, 70}}, color = {0, 0, 255}));
  connect(switch.n2, ground.p) annotation(
    Line(points = {{-52, 74}, {-98, 74}, {-98, -56}, {-70, -56}}, color = {0, 0, 255}));
  connect(inductor.p, resistor.n) annotation(
    Line(points = {{30, 34}, {30, 50}}, color = {0, 0, 255}));
  connect(realExpression.y, inductor.L) annotation(
    Line(points = {{58, 24}, {42, 24}}, color = {0, 0, 127}));
  connect(capacitor.p, inductor.n) annotation(
    Line(points = {{30, -14}, {30, 14}}, color = {0, 0, 255}));
  connect(booleanPulse.y, switch.control) annotation(
    Line(points = {{-34, 20}, {-16, 20}, {-16, 48}, {-42, 48}, {-42, 62}, {-42, 62}}, color = {255, 0, 255}));
  annotation(
    uses(Modelica(version = "3.2.3")));
end Test3;

  • Index
  • » Users
  • » Getudan
  • » Profile
You are here: