Changeset 7df27713 in OpenModelica


Ignore:
Timestamp:
2019-01-15T13:16:37+01:00 (5 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, master, omlib-staging
Children:
d663c40
Parents:
a5b0f222
git-author:
Lennart Ochel <lennart.ochel@…> (01/15/19 13:16:37)
git-committer:
hudson <openmodelica@…> (01/15/19 13:16:37)
Message:

Update DualMassOscillator.mo

Belonging to [master]:

  • OpenModelica/OpenModelica-testsuite#1104
Location:
omsimulator
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • omsimulator/DualMassOscillator.mo

    ra5b0f222 r7df27713  
    99    Modelica.Mechanics.Translational.Components.Fixed fixed(s0=0.0) annotation(
    1010      Placement(transformation(extent={{-10,-10}, {10,10}}, rotation=0, origin={-70,0})));
    11     Modelica.Mechanics.Translational.Components.Mass mass1(m=m1, s(fixed=true, start=s1_start), v(fixed=true, start=v1_start), L=0.0) annotation(
     11    Modelica.Mechanics.Translational.Components.Mass mass1( L=0.0, m=m1, s(fixed=true, start=s1_start), v(fixed=true, start=v1_start)) annotation(
    1212      Placement(transformation(extent={{-14,-10}, {6,10}})));
    1313    Modelica.Mechanics.Translational.Components.SpringDamper springDamper1(c=c1, d=d1, s_rel0=1.0) annotation(
     
    2323    Modelica.Blocks.Interfaces.RealInput F annotation(
    2424      Placement(transformation(extent={{120,-10}, {100,10}}), iconTransformation(extent={{120,-10}, {100,10}})));
    25     Modelica.Blocks.Interfaces.RealOutput s annotation(
     25    Modelica.Blocks.Interfaces.RealOutput s1 annotation(
    2626      Placement(transformation(extent={{100,-40}, {120,-20}}), iconTransformation(extent={{100,-40}, {120,-20}})));
    27     Modelica.Blocks.Interfaces.RealOutput v annotation(
     27    Modelica.Blocks.Interfaces.RealOutput v1 annotation(
    2828      Placement(transformation(extent={{100,-60}, {120,-40}}), iconTransformation(extent={{100,-60}, {120,-40}})));
    29     Modelica.Blocks.Interfaces.RealOutput a annotation(
     29    Modelica.Blocks.Interfaces.RealOutput a1 annotation(
    3030      Placement(transformation(extent={{100,-80}, {120,-60}}), iconTransformation(extent={{100,-80}, {120,-60}})));
    3131  equation
     
    4242    connect(force.flange, mass1.flange_b) annotation(
    4343      Line(points={{20,0}, {6,0}}, color={0,127,0}));
    44     connect(accSensor.a, a) annotation(
     44    connect(accSensor.a, a1) annotation(
    4545      Line(points={{41,-70}, {110,-70}}, color={0,0,127}));
    46     connect(speedSensor.v, v) annotation(
     46    connect(speedSensor.v, v1) annotation(
    4747      Line(points={{41,-50}, {110,-50}}, color={0,0,127}));
    48     connect(positionSensor.s, s) annotation(
     48    connect(positionSensor.s, s1) annotation(
    4949      Line(points={{41,-30}, {110,-30}}, color={0,0,127}));
    5050    connect(force.f, F) annotation(
     
    6262    parameter Real dc = 14.1421;
    6363
     64    Real s2 = mass2.s;
     65
    6466    Modelica.Mechanics.Translational.Components.Fixed fixed(s0=3.0) annotation(
    6567      Placement(transformation(extent={{80, -10}, {100, 10}})));
    66     Modelica.Mechanics.Translational.Components.Mass mass2(m=m2, s(fixed=true, start=s2_start), v(fixed=true, start=v2_start), L=0.0) annotation(
     68    Modelica.Mechanics.Translational.Components.Mass mass2( L=0.0, m=m2, s(fixed=true, start=s2_start), v(fixed=true, start=v2_start)) annotation(
    6769      Placement(transformation(extent={{20, -10}, {40, 10}})));
    6870    Modelica.Mechanics.Translational.Components.SpringDamper springDamper2(c=c2, d=d2, s_rel0=1.0) annotation(
     
    7274    Modelica.Blocks.Interfaces.RealOutput F annotation(
    7375      Placement(transformation(extent={{-100, -10}, {-120, 10}})));
    74     Modelica.Blocks.Interfaces.RealInput s annotation(
     76    Modelica.Blocks.Interfaces.RealInput s1 annotation(
    7577      Placement(transformation(extent={{-120, -40}, {-100, -20}})));
    76     Modelica.Blocks.Interfaces.RealInput v annotation(
     78    Modelica.Blocks.Interfaces.RealInput v1 annotation(
    7779      Placement(transformation(extent={{-120, -60}, {-100, -40}})));
    78     Modelica.Blocks.Interfaces.RealInput a annotation(
     80    Modelica.Blocks.Interfaces.RealInput a1 annotation(
    7981      Placement(transformation(extent={{-120, -80}, {-100, -60}})));
    8082    Modelica.Mechanics.Translational.Sensors.ForceSensor forceSensor annotation(
     
    8587    connect(forceSensor.f, F) annotation(
    8688      Line(points={{-22, 11}, {-90, 11}, {-90, 0}, {-110, 0}}, color={0,0,127}));
    87     connect(s, move.u[1]) annotation(
     89    connect(s1, move.u[1]) annotation(
    8890      Line(points={{-110, -30}, {-80, -30}, {-80, -1.33333}, {-70, -1.33333}}, color={0,0,127}));
    89     connect(v, move.u[2]) annotation(
     91    connect(v1, move.u[2]) annotation(
    9092      Line(points={{-110, -50}, {-80, -50}, {-80, 0}, {-70, 0}}, color={0,0,127}));
    91     connect(a, move.u[3]) annotation(
     93    connect(a1, move.u[3]) annotation(
    9294      Line(points={{-110, -70}, {-80, -70}, {-80, 1.33333}, {-70, 1.33333}}, color={0,0,127}));
    9395    connect(springDamper_coupling.flange_b, mass2.flange_a) annotation(
     
    107109    System1 system1 annotation(
    108110      Placement(transformation(extent={{-30, -10}, {-10, 10}})));
    109     System2 system2(s2_start=2.5) annotation(
     111    System2 system2 annotation(
    110112      Placement(transformation(extent={{10, -10}, {30, 10}})));
    111113  equation
    112114    connect(system2.F, system1.F) annotation(
    113115      Line(points={{9, 0}, {-9, 0}}, color={0,0,127}));
    114     connect(system1.s, system2.s) annotation(
     116    connect(system1.s1, system2.s1) annotation(
    115117      Line(points={{-9, -3}, {-9, -3}, {9, -3}}, color={0,0,127}));
    116     connect(system1.v, system2.v) annotation(
     118    connect(system1.v1, system2.v1) annotation(
    117119      Line(points={{-9, -5}, {-9, -5}, {9, -5}}, color={0,0,127}));
    118     connect(system1.a, system2.a) annotation(
     120    connect(system1.a1, system2.a1) annotation(
    119121      Line(points={{-9, -7}, {-9, -7}, {9, -7}}, color={0,0,127}));
    120122    annotation(Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false)));
     
    125127    parameter Real v1_start = 0.0;
    126128    parameter Real m1 = 1.0;
    127     parameter Real s2_start = 2.5;
     129    parameter Real s2_start = 2.0;
    128130    parameter Real v2_start = 0.0;
    129131    parameter Real m2 = 1.0;
     
    135137    parameter Real dc = 14.1421;
    136138
     139    Real s1 = mass1.s;
     140    Real s2 = mass2.s;
     141
    137142    Modelica.Mechanics.Translational.Components.Fixed fixed(s0=0.0) annotation(
    138143      Placement(transformation(extent={{-10, 10}, {10, -10}}, rotation=90, origin={-86, 0})));
    139     Modelica.Mechanics.Translational.Components.Mass mass1(m=m1, v(fixed=true, start=v1_start), L=0.0, s(fixed=true, start=s1_start)) annotation(
     144    Modelica.Mechanics.Translational.Components.Mass mass1( L=0.0, m=m1, s(fixed=true, start=s1_start), v(fixed=true, start=v1_start)) annotation(
    140145      Placement(transformation(extent={{-40, -10}, {-20, 10}})));
    141146    Modelica.Mechanics.Translational.Components.SpringDamper springDamper1(c=c1, d=d1, s_rel0=1.0) annotation(
     
    143148    Modelica.Mechanics.Translational.Components.Fixed fixed1(s0=3.0) annotation(
    144149      Placement(transformation(extent={{-10, -10}, {10, 10}}, rotation=90, origin={86, 0})));
    145     Modelica.Mechanics.Translational.Components.Mass mass2(m=m2, v(fixed=true, start=v2_start), L=0.0, s(fixed=true, start=s2_start)) annotation(
     150    Modelica.Mechanics.Translational.Components.Mass mass2( L=0.0, m=m2, s(fixed=true, start=s2_start), v(fixed=true, start=v2_start)) annotation(
    146151      Placement(transformation(extent={{20, -10}, {40, 10}})));
    147152    Modelica.Mechanics.Translational.Components.SpringDamper springDamper2(c=c2, d=d2, s_rel0=1.0) annotation(
  • omsimulator/DualMassOscillator_me.mos

    ra5b0f222 r7df27713  
    1818
    1919oms3_addConnection(\"DualMassOscillator.root.system1.F\", \"DualMassOscillator.root.system2.F\")
    20 oms3_addConnection(\"DualMassOscillator.root.system1.s\", \"DualMassOscillator.root.system2.s\")
    21 oms3_addConnection(\"DualMassOscillator.root.system1.v\", \"DualMassOscillator.root.system2.v\")
    22 oms3_addConnection(\"DualMassOscillator.root.system1.a\", \"DualMassOscillator.root.system2.a\")
     20oms3_addConnection(\"DualMassOscillator.root.system1.s1\", \"DualMassOscillator.root.system2.s1\")
     21oms3_addConnection(\"DualMassOscillator.root.system1.v1\", \"DualMassOscillator.root.system2.v1\")
     22oms3_addConnection(\"DualMassOscillator.root.system1.a1\", \"DualMassOscillator.root.system2.a1\")
    2323
    2424oms3_setResultFile(\"DualMassOscillator\", \"\")
     
    3232oms3_initialize(\"DualMassOscillator\")
    3333print(\"info:    Initialization\")
    34 print(\"info:      system1.mass1.s: \" .. oms3_getReal(\"DualMassOscillator.root.system1.mass1.s\"))
    35 print(\"info:      system2.mass2.s: \" .. oms3_getReal(\"DualMassOscillator.root.system2.mass2.s\"))
     34print(\"info:      system1.s1: \" .. oms3_getReal(\"DualMassOscillator.root.system1.s1\"))
     35print(\"info:      system2.s2: \" .. oms3_getReal(\"DualMassOscillator.root.system2.s2\"))
    3636
    3737oms3_simulate(\"DualMassOscillator\")
    3838print(\"info:    Simulation\")
    39 print(\"info:      system1.mass1.s: \" .. oms3_getReal(\"DualMassOscillator.root.system1.mass1.s\"))
    40 print(\"info:      system2.mass2.s: \" .. oms3_getReal(\"DualMassOscillator.root.system2.mass2.s\"))
     39print(\"info:      system1.s1: \" .. oms3_getReal(\"DualMassOscillator.root.system1.s1\"))
     40print(\"info:      system2.s2: \" .. oms3_getReal(\"DualMassOscillator.root.system2.s2\"))
    4141
    4242oms3_terminate(\"DualMassOscillator\")
     
    4646system(getInstallationDirectoryPath() + "/bin/OMSimulator --ignoreInitialUnknowns=true DualMassOscillator_me.lua");
    4747
    48 simulate(DualMassOscillator.CoupledSystem, stopTime=0.1); getErrorString();
    49 val(system1.mass1.s, {0.0,0.1});
    50 val(system2.mass2.s, {0.0,0.1});
     48simulate(DualMassOscillator.CoupledSystem, stopTime=0.1, simflags="-override=system2.s2_start=2.5"); getErrorString();
     49val(system1.s1, {0.0,0.1});
     50val(system2.s2, {0.0,0.1});
    5151
    5252// Result:
     
    6565// info:    No result file will be created
    6666// info:    Initialization
    67 // info:      system1.mass1.s: 1.0
    68 // info:      system2.mass2.s: 2.5
     67// info:      system1.s1: 1.0
     68// info:      system2.s2: 2.5
    6969// info:    Simulation
    70 // info:      system1.mass1.s: 0.9112797974079
    71 // info:      system2.mass2.s: 1.9556338147396
     70// info:      system1.s1: 0.9112797974079
     71// info:      system2.s2: 1.9556338147396
    7272// info:    Final Statistics for 'DualMassOscillator.root':
    7373//          NumSteps = 1301 NumRhsEvals  = 1545 NumLinSolvSetups = 138
     
    7676// record SimulationResult
    7777//     resultFile = "DualMassOscillator.CoupledSystem_res.mat",
    78 //     simulationOptions = "startTime = 0.0, stopTime = 0.1, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'DualMassOscillator.CoupledSystem', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
     78//     simulationOptions = "startTime = 0.0, stopTime = 0.1, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'DualMassOscillator.CoupledSystem', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-override=system2.s2_start=2.5'",
    7979//     messages = "LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
    8080// LOG_SUCCESS       | info    | The simulation finished successfully.
Note: See TracChangeset for help on using the changeset viewer.