- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Crash and Close the window when I run...
Crash and Close the window when I run a specific model
Crash and Close the window when I run a specific model
I often make models with OMEdit.
One day I tried to run a model but it didn’t work and suddenly crash, close the window without any error, warning message.(I was able to simulate it within a month)
I can run other models except for “Motor_IPMSM”.
I did uninstalling OpenModelica, reinstalling and restarting PC, but nothing was changed.
Let me show you my model script to identify what is wrong in my model script.
Thank you
---Motor_IPMSM------
model Motor_IPMSM
//electronical variables
Modelica.Units.SI.Voltage v_d(start = 0), v_q(start = 0), v_o(start = 0);
flow Modelica.Units.SI.Current i_d(start = 0), i_q(start = 0), i_o(start = 0);
Modelica.Units.SI.Angle phi_e(start = 0);
Modelica.Units.SI.AngularVelocity omega_m(start = 0), omega_e(start = 0);
flow Modelica.Units.SI.Torque tau_e;
Real Pj ,Pi;
Real i_od, i_oq, i_cd, i_cq;
//mathmatical numbers
constant Real n2om = 4.0 * asin(1.0) / 60.0;
constant Real om2n = 60.0 / (4.0 * asin(1.0));
constant Real two_third_pi = 4.0 / 3.0 * asin(1.0);//parameter with initial definitions
constant Real rpm2rad = 2 * Modelica.Constants.pi / 60;
parameter Real L_d = L_d, L_q = L_q, L_o = (L_d + L_q) / 2.0;//inductance
parameter Real lambda_pm = lambda_pm;//mutual flux linkage [kg*m^2/s^2*A].
parameter Real r_s = r_s, r_c = r_c;
parameter Real p = p;//numbers of pole, twice of number of pole
parameter Real series = series;
parameter Real gear_rate = gear_rate;//pin declare
Modelica.Mechanics.Rotational.Interfaces.Flange_a Mec annotation(
Placement(visible = true, transformation(origin = {100, 42}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 44}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealInput av annotation(
Placement(visible = true, transformation(origin = {-100, 90}, extent = {{-20, -20}, {20, 20}}, rotation = 180), iconTransformation(origin = {-120, 100}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealInput bv annotation(
Placement(visible = true, transformation(origin = {-120, 28}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, 24}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealInput cv annotation(
Placement(visible = true, transformation(origin = {-120, -50}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, -52}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealOutput ai annotation(
Placement(visible = true, transformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180), iconTransformation(origin = {-118, 74}, extent = {{-20, -20}, {20, 20}}, rotation = 180)));
Modelica.Blocks.Interfaces.RealOutput bi annotation(
Placement(visible = true, transformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180), iconTransformation(origin = {-118, -2}, extent = {{-20, -20}, {20, 20}}, rotation = 180)));
Modelica.Blocks.Interfaces.RealOutput ci annotation(
Placement(visible = true, transformation(origin = {-110, -76}, extent = {{-10, -10}, {10, 10}}, rotation = 180), iconTransformation(origin = {-118, -78}, extent = {{-20, -20}, {20, 20}}, rotation = 180)));
Modelica.Blocks.Interfaces.RealOutput loss_motor annotation(
Placement(visible = true, transformation(origin = {2, -110}, extent = {{-10, -10}, {10, 10}}, rotation = -90), iconTransformation(origin = {-2.66454e-15, -120}, extent = {{-22, -22}, {22, 22}}, rotation = -90)));
Real motor_output_power;
Real Inverter_output_power;
Modelica.Blocks.Interfaces.RealOutput i_do annotation(
Placement(visible = true, transformation(origin = {2, -110}, extent = {{-10, -10}, {10, 10}}, rotation = -90), iconTransformation(origin = {-50, 118}, extent = {{-20, -20}, {20, 20}}, rotation = 90)));
Modelica.Blocks.Interfaces.RealOutput i_qo annotation(
Placement(visible = true, transformation(origin = {2, -110}, extent = {{-10, -10}, {10, 10}}, rotation = -90), iconTransformation(origin = {2, 118}, extent = {{-20, -20}, {20, 20}}, rotation = 90)));
equation
//Asserting declare
assert(L_d > 0.0 and L_q > 0.0, "ERROR: inductance of stator should be greater than 0.0.", level = AssertionLevel.error);
assert(lambda_pm > 0.0, "ERROR: mutual flux linkage should be greater than 0.0.", level = AssertionLevel.error);
assert(r_s >= 0.0, "ERROR: stator resistance should be greater or equal to 0.0.", level = AssertionLevel.error);
assert(p >= 2.0, "ERROR: numbers of poles should be greater than 2 and should be multiples of 2.", level = AssertionLevel.error);
// Park's Transformation
av = sqrt(2 / 3) * (cos(phi_e) * v_d - sin(phi_e) * v_q + sqrt(1 / 2) * v_o);
bv = sqrt(2 / 3) * (cos(phi_e - two_third_pi) * v_d - sin(phi_e - two_third_pi) * v_q + sqrt(1 / 2) * v_o);
cv = sqrt(2 / 3) * (cos(phi_e + two_third_pi) * v_d - sin(phi_e + two_third_pi) * v_q + sqrt(1 / 2) * v_o);
ai = sqrt(2 / 3) * (cos(phi_e) * i_d - sin(phi_e) * i_q + i_o) / series;
bi = sqrt(2 / 3) * (cos(phi_e - two_third_pi) * i_d - sin(phi_e - two_third_pi) * i_q + i_o) / series;
ci = sqrt(2 / 3) * (cos(phi_e + two_third_pi) * i_d - sin(phi_e + two_third_pi) * i_q + i_o) / series;
//output current for controll
i_do = i_d;
i_qo = i_q;
// dynamic equations
L_d * der(i_d) = v_d - r_s * i_d + omega_e * L_q * i_q;
L_q * der(i_q) = v_q - r_s * i_q - omega_e * L_d * i_d - omega_e * lambda_pm;
L_o * der(i_o) = v_o - r_s * i_o;
// electrical torque
tau_e = p / 2.0 * lambda_pm * i_q;
//power relation
motor_output_power = omega_m * tau_e;
Inverter_output_power = series * (ai * av + bi * bv + ci * cv);
// Relation between angle and anglevelosity
der(phi_e) = omega_e;
omega_e = omega_m * p / 2.0;
//equqtion for output
Mec.tau * gear_rate = -tau_e;
omega_m * gear_rate = der(Mec.phi);
//equation for loss calculation
i_cd = -omega_e * L_q * i_oq / r_c;
i_cq = omega_e * (lambda_pm + L_d * i_od) / r_c;
i_od = i_d - i_cd;
i_oq = i_q - i_cq;
Pj = r_s * sqrt(i_d ^ 2 + i_q ^ 2);
Pi = omega_e * sqrt((L_d * i_od + lambda_pm) ^ 2 + (L_q * i_oq) ^ 2) / r_c;
loss_motor = Pj + Pi;
annotation(
Icon(coordinateSystem(grid = {4, 4})));
end Motor_IPMSM;
-------------------------
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Crash and Close the window when I run...