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

Explanation about Modelica.Electrical.Analog.Sources.ConstantVoltage

Explanation about Modelica.Electrical.Analog.Sources.ConstantVoltage

Hi, I'm learning about writing equations in open modelica.
The following is the program code of Modelica.Electrical.Analog.Sources.StepVoltage

Code:


class Modelica.Electrical.Analog.Sources.StepVoltage "Step voltage source"
  Real v(quantity = "ElectricPotential", unit = "V") "Voltage drop between the two pins (= p.v - n.v)";
  Real i(quantity = "ElectricCurrent", unit = "A") "Current flowing from pin p to pin n";
  Real p.v(quantity = "ElectricPotential", unit = "V") "Potential at the pin";
  Real p.i(quantity = "ElectricCurrent", unit = "A") "Current flowing into the pin";
  Real n.v(quantity = "ElectricPotential", unit = "V") "Potential at the pin";
  Real n.i(quantity = "ElectricCurrent", unit = "A") "Current flowing into the pin";
  parameter Real offset(quantity = "ElectricPotential", unit = "V") = 0.0 "Voltage offset";
  parameter Real startTime(quantity = "Time", unit = "s") = 0.0 "Time offset";
  Real signalSource.y "Connector of Real output signal";
  parameter Real signalSource.offset = offset "Offset of output signal y";
  parameter Real signalSource.startTime(quantity = "Time", unit = "s") = startTime "Output y = offset for time < startTime";
  parameter Real signalSource.height = V "Height of step";
  parameter Real V(quantity = "ElectricPotential", unit = "V", start = 1.0) "Height of step";
equation
  signalSource.y = signalSource.offset + (if time < signalSource.startTime then 0.0 else signalSource.height);
  v = signalSource.y;
  v = p.v - n.v;
  0.0 = p.i + n.i;
  i = p.i;
  p.i = 0.0;
  n.i = 0.0;
end Modelica.Electrical.Analog.Sources.StepVoltage;

I want to know the explanation in the following sections :


Code:


v = signalSource.y;
v = p.v - n.v;

1.Why does the "v" expression need to be written twice?

Code:


p.i = 0.0;
n.i = 0.0;

2. What is the purpose of having these two lines of code ? Why are the two lines of code written at the end?

Thank you

Edited by: nugrohoav - Dec-11-19 16:32:11
There are 0 guests and 0 other users also viewing this topic
You are here: