// Script to generate plot for documentation of
// function PressureLoss.StraightPipe.dp_laminar_DP and dp_laminar_MFLOw
// of FluidDissipation Library
//
// Generated by Thorben Vahlenkamp
// 04-04-2008
// last change: 25-05-2009
// XRG Simulation GmbH

currentDirectory = Modelica.Utilities.System.getWorkDirectory();
cd(Modelica.Utilities.System.getEnvironmentVariable("temp"));

translateModel("ModelicaTest.Fluid.Dissipation.Verifications.PressureLoss.StraightPipe.dp_laminar_DPMFLOW");

Advanced.StoreProtectedVariables:=true;

simulateModel("ModelicaTest.Fluid.Dissipation.Verifications.PressureLoss.StraightPipe.dp_laminar_DPMFLOW",startTime=0, stopTime=1, numberOfIntervals=5000, method="dassl", tolerance=1e-005, resultFile="dp_laminar_DPMFLOW");

switchToSimulationMode();

removePlots();
createPlot(id = 1,
 position = {(-2), (-21), 708, 403},
x="Re[1]",
 y = {
	"lambda_FRI[1]"

},
  heading = "Straight pipe (inverse): Pressure loss for laminar flow regime (d_hyd= 0.1m, L=1m)",
 range = {6e2, 1e6, 1e-1, 1e-2},
 autoscale = false,
 autoerase = false,
 autoreplot = true,
 description = false,
 grid = true,
 color = true,
 online = false,
 filename = "dp_laminar_DPMFLOW.mat",
 logX = true,
 logY = true,
 legends = {
	"Hagen-Poisseuille"
},
 leftTitle = "Darcy friction factor (lambda_FRI [-])",
 bottomTitle = "Reynolds number [-]");

createPlot(id = 2,
 position = {(-2), 400, 708, 403},
 x = "DP_plot[1]",
 y = {
	"input_mdot[1]"

},
 heading = "Straight pipe (inverse): Pressure loss for laminar flow regime (Water, d_hyd= 0.1m, L=1m)",
 range = {0, 40,100, 0},
 autoscale = false,
 autoerase = false,
 autoreplot = true,
 description = false,
 grid = true,
 color = true,
 online = false,
 filename = "dp_laminar_DPMFLOW.mat",
 legends = {
	"Hagen-Poisseuille"
},
 leftTitle = "Mass flow rate [kg/s]",
 bottomTitle = "Pressure loss [Pa]");

createPlot(id = 5,
   position = {375, 177, 708, 412},
x="input_mdot[1]",
 y = {
	"input_mdot[1]",
	"M_FLOW[1]"
},
 heading = "Check",
 range = {0, 0.1, 5e5, 0},
 autoscale = true,
 autoerase = true,
 autoreplot = true,
 description = false,
 grid = true,
 color = true,
 online = false,
 filename = "dp_laminar_DPMFLOW.mat",
 leftTitle = "(Output) mass flow rate [kg/s]",
 bottomTitle ="(Input) Mass flow rate [kg/s]");

Modelica.Utilities.System.setWorkDirectory(currentDirectory);
