1 | /* A simple script to run my Plant Model
|
---|
2 | Author: Ravi Saripalli
|
---|
3 | Date: 24 May. 2014
|
---|
4 | Version 3.0
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*************** Load Models *********/
|
---|
8 | echo(false) ;
|
---|
9 | print(getSettings());
|
---|
10 | cd("./work");
|
---|
11 | loadFile("../plant.mo");
|
---|
12 | loadFile("../Reservoir.mo");
|
---|
13 | loadFile("../MyGas.mo");
|
---|
14 | //ThermoS.Util.ldFile("../plant.mo"); // The main plant simulation
|
---|
15 | //ThermoS.Util.ldFile("../summary.mo"); // enable summary reports
|
---|
16 | cd("..");
|
---|
17 | print("Checking Model \n");
|
---|
18 | ans:=checkModel(plant);
|
---|
19 | getErrorString();
|
---|
20 | print("Checked Model \n");
|
---|
21 | /************ Cleanup Work **********/
|
---|
22 | print("Cleaning Up Work Area\n") ;
|
---|
23 | system("rm work/*");
|
---|
24 | cd("./work"); // Do all the dirty work here
|
---|
25 | system("pwd");
|
---|
26 |
|
---|
27 |
|
---|
28 | /* if you don't set timeStep it is calculated as (stopTime-startTime)/count
|
---|
29 | which can be bad news fi you set too large a stopTime this really
|
---|
30 | caught me off gaurd, lost few weeks of effor */
|
---|
31 |
|
---|
32 | tEnd := 5;
|
---|
33 | iniStepSize := 1 ;
|
---|
34 | count := integer(floor(tEnd / iniStepSize)) ;
|
---|
35 |
|
---|
36 | setDebugFlags("infoXmlOperations,failtrace");
|
---|
37 | flags := "-lv=LOG_NLS" ;
|
---|
38 |
|
---|
39 | print("Starting the Plant \n");
|
---|
40 | simulate(plant);
|
---|
41 | /*
|
---|
42 | simulate(plant, startTime=0, outputFormat="mat",
|
---|
43 | stopTime=tEnd, tolerance=1e-6, // numberOfIntervals=count,
|
---|
44 | simflags=flags) ;
|
---|
45 | */
|
---|
46 | // cflags="-ffloat-store", simflags=flags) ;
|
---|
47 |
|
---|
48 | getErrorString();
|
---|
49 | sVars := readSimulationResultVars("plant_res.mat") ;
|
---|
50 | //print(sVars);
|
---|
51 | if (size(sVars,1) == 0) then // no variables then bailout
|
---|
52 | print("simulation failed ... bailing out\n");
|
---|
53 | else
|
---|
54 | print("simulation done\n");
|
---|
55 | print("No. of Plant Variables = " + String(size(sVars,1)) + "\n");
|
---|
56 | end if;
|
---|
57 | echo(true);
|
---|
58 | //Summary.genReport("plant_res.mat", "htr", 5);
|
---|