/**
* Assigns a graph to a name so we can do things with it
*/
let energyPlot = Graph.GetFromID(1);
energyPlot.active = Graph.YES;
/**
* Removes any pre-existing curves from graph 1
*/
let existingCurves = Curve.First();
while (existingCurves) {
existingCurves.RemoveFromGraph(1);
existingCurves = existingCurves.Next();
}
/**
* Removes any pre-existing datums from graph 1
*/
let exisitngDatums = Datum.First();
while (exisitngDatums) {
exisitngDatums.RemoveFromGraph(1);
exisitngDatums = exisitngDatums.Next();
}
/* Contour relative to the current state in model 1 */
/**
* Gets the workflow information
*/
let model_id = Workflow.ModelIdFromIndex(0);
let unit_system = Workflow.ModelUnitSystemFromIndex(0);
let unit_system_string = "undefined";
switch (unit_system) {
case Workflow.UNIT_SYSTEM_NONE:
unit_system_string = "undefined";
break;
case Workflow.UNIT_SYSTEM_U1:
unit_system_string = "U1";
break;
case Workflow.UNIT_SYSTEM_U2:
unit_system_string = "U2";
break;
case Workflow.UNIT_SYSTEM_U3:
unit_system_string = "U3";
break;
case Workflow.UNIT_SYSTEM_U4:
unit_system_string = "U4";
break;
case Workflow.UNIT_SYSTEM_U5:
unit_system_string = "U5";
break;
case Workflow.UNIT_SYSTEM_U6:
unit_system_string = "U6";
break;
default:
unit_system_string = "undefined";
}
/**
* Set model and display units using dialogue command
*/
DialogueInput("UNITS MO " + model_id, unit_system_string);
DialogueInput("UNITS DI " + unit_system_string);
/**
* Read in energy curves for this model
*/
let m = Model.GetFromID(model_id);
let components = [Component.GKE, Component.GIE, Component.GTE, Component.GHG];
/**
* Loops through the components, if there is data in them then assigns unit system to them and then assigns curve to a name so we can do things with it
*/
for (let i = 0; i < components.length; i++) {
if ((m.QueryDataPresent, components[i])) {
let curve = m.GetDataFlagged(0, components[i]); //this makes an array of curves where data exists
curve[0].unit_system = unit_system; // sets the unit system for each curve
curve[0].style = LineStyle.SOLID; // sets the lines to be solid for each curve
if (i == 0) {
var kineticEnergy = curve[0]; // curve is zero each time beacause each time it goes through the for loop the curve array resets
} else if (i == 1) {
var internalEnergy = curve[0];
} else if (i == 2) {
var totalEnergy = curve[0];
} else if (i == 3) {
var hourglassEnergy = curve[0];
}
}
}
/**
* Plots the curves
*/
Plot();
/**
* Changes graph title and curve colours using the assignments made previously
*/
energyPlot.title = "Energy Check";
energyPlot.auto_xlabel = Graph.YES;
energyPlot.auto_ylabel = Graph.YES;
kineticEnergy.colour = Colour.BLUE;
internalEnergy.colour = Colour.RED;
totalEnergy.colour = Colour.FOREGROUND;
hourglassEnergy.colour = Colour.GREEN;
DialogueInput("/AU");