.IDEAS.LIDEAS.Examples.ZoneLinearise

Information

This model represents a very simple two-zone building. The model can be linearised by executing the command Linearise in the Commands menu of Dymola. This executes the script at LIDEAS/LIDEAS/Resources/Scripts/linearize.mos, which contains the following code:


OutputCPUtime:=false;

// linearise model and save results in "re"
re=Modelica_LinearSystems2.ModelAnalysis.Linearize("IDEAS.LIDEAS.Examples.ZoneLinearise");

// extract state space matrices from 're' and save them to a mat file in the current working directory
writeMatrix(fileName="ssm_ZoneLinearise.mat",matrixName="A",matrix=re.A);
writeMatrix(fileName="ssm_ZoneLinearise.mat",matrixName="B",matrix=re.B, append=true);
writeMatrix(fileName="ssm_ZoneLinearise.mat",matrixName="C",matrix=re.C, append=true);
writeMatrix(fileName="ssm_ZoneLinearise.mat",matrixName="D",matrix=re.D, append=true);

// save the variable names of the inputs, outputs and states in the current working directory
Modelica.Utilities.Files.remove("uNames_ZoneLinearise.txt");
for i in 1:size(re.uNames,1) loop Modelica.Utilities.Streams.print(re.uNames[i], "uNames_ZoneLinearise.txt"); end for;
Modelica.Utilities.Files.remove("yNames_ZoneLinearise.txt");
for i in 1:size(re.yNames,1) loop Modelica.Utilities.Streams.print(re.yNames[i], "yNames_ZoneLinearise.txt"); end for;
Modelica.Utilities.Files.remove("xNames_ZoneLinearise.txt");
for i in 1:size(re.xNames,1) loop Modelica.Utilities.Streams.print(re.xNames[i], "xNames_ZoneLinearise.txt"); end for;

OutputCPUtime:=true;

The first and last line of the code avoid that the CPU time is also linearised. The second line performs the actual linearisation and stores the resulting state space model in variable re. The next four lines are used to save the four state space matrices contained by re to a file ssm.mat. The remaining four lines of code also export the variable names of the state space inputs (u), states (x) and outputs (y) to three .txt files, which can then be used externally.

Contents

NameDescription
 Medium

Revisions


Generated at 2024-11-21T19:25:40Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos