modelica / ModelicaStandardLibrary

Free (standard conforming) library to model mechanical (1D/3D), electrical (analog, digital, machines), magnetic, thermal, fluid, control systems and hierarchical state machines. Also numerical functions and functions for strings, files and streams are included.
https://doc.modelica.org
BSD 3-Clause "New" or "Revised" License
452 stars 165 forks source link

Revisit example LightningSegmentedTransmissionLine #4315

Closed AHaumer closed 4 months ago

AHaumer commented 4 months ago

... i.e. excessive size of the simulation result.

  1. The elements R[N+1], L[N+1], G[N] and C[N] are protected again, but voltages v[N] and currents i[N+1] are mirrored to to alias variables to be able to initialize and to track traveling waves along the line.
  2. The output interval of the example has been relaxed to 1e-6,
  3. The comparisonSignals,txt has been updated: It doesn't make sense to compare both current and voltage at the load resistor, but the voltage in the middle of the line is useful.
AHaumer commented 4 months ago

@beutlich Somehow I don't understand your result file sizes. Dymola 2024x on Windows 11: grafik How does this compare to your 890.394.816 bytes (21 times my size)?

beutlich commented 4 months ago

Dymola regression testing uses stricter settings on solver tolerance and output interval:

// Experiment settings (standardized annotation)
StartTime=0
StopTime=0.025 // from model
Interval=5e-07 // used annotation from model, multiplied by 0.5
Tolerance=1e-07 // used annotation from model, multiplied by 0.1

// Experiment settings (tool specific)
// The following lines can be used as mos-script in Dymola
Advanced.PedanticModelica := false;
Evaluate := false;
OutputCPUtime := false;
translateModel("Modelica.Electrical.Analog.Examples.Lines.LightningSegmentedTransmissionLine");
Advanced.StoreProtectedVariables := true;
Advanced.EfficientMinorEvents := false;
Advanced.PlaceDymolaSourceFirst := 2;
experimentSetupOutput(
  textual=false,
  doublePrecision=true,
  states=true,
  derivatives=true,
  inputs=true,
  outputs=true,
  auxiliaries=true,
  equidistant=true,
  events=true,
  debug=false);
simulateModel(
  problem="Modelica.Electrical.Analog.Examples.Lines.LightningSegmentedTransmissionLine",
  startTime=0,
  stopTime=0.025,
  outputInterval=5e-07,
  method="Dassl",
  tolerance=1e-07,
  resultFile="LightningSegmentedTransmissionLine");
HansOlsson commented 4 months ago
AHaumer commented 4 months ago

@HansOlsson no the changes in the diagram are just shifting the "lightning" a little bit to the middle, looks better now. The components R[N+1], L[N+1], G[N] and C[N] in OLine have been protected previously. Then I "unprotected" them to be able to initialize the model properly. Now I protected them again to save size of the result, but introduced alias variables for initialization. What's the problem? We have an improved situation.

HansOlsson commented 4 months ago

@HansOlsson no the changes in the diagram are just shifting the "lightning" a little bit to the middle, looks better now. The components R[N+1], L[N+1], G[N] and C[N] in OLine have been protected previously. Then I "unprotected" them to be able to initialize the model properly. Now I protected them again to save size of the result, but introduced alias variables for initialization. What's the problem? We have an improved situation.

I was not aware of those details, but based on that it seems ok.