From: niemisto Date: Tue, 26 Jan 2010 15:41:25 +0000 (+0000) Subject: git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@13645 ac1ea38d-2e2b... X-Git-Tag: simantics-1.0~95 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=c4d89fa6815c3a3d753ae548021ee1586d8ce3a7;p=simantics%2Fsysdyn.git git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@13645 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.modelica/.classpath b/org.simantics.modelica/.classpath new file mode 100644 index 00000000..8a8f1668 --- /dev/null +++ b/org.simantics.modelica/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.simantics.modelica/.project b/org.simantics.modelica/.project new file mode 100644 index 00000000..2d4d7aa0 --- /dev/null +++ b/org.simantics.modelica/.project @@ -0,0 +1,28 @@ + + + org.simantics.modelica + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.simantics.modelica/.settings/org.eclipse.jdt.core.prefs b/org.simantics.modelica/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f25d3a62 --- /dev/null +++ b/org.simantics.modelica/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Tue Jan 26 16:43:56 EET 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.simantics.modelica/META-INF/MANIFEST.MF b/org.simantics.modelica/META-INF/MANIFEST.MF new file mode 100644 index 00000000..5694d315 --- /dev/null +++ b/org.simantics.modelica/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Modelica +Bundle-SymbolicName: org.simantics.modelica +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: gnu.trove2;bundle-version="2.0.4" diff --git a/org.simantics.modelica/Testi2.cpp b/org.simantics.modelica/Testi2.cpp new file mode 100644 index 00000000..e1f28e0d --- /dev/null +++ b/org.simantics.modelica/Testi2.cpp @@ -0,0 +1,498 @@ +// Simulation code for Testi2 generated by the OpenModelica Compiler. +#include "modelica.h" +#include "assert.h" +#include "string.h" +#include "simulation_runtime.h" + +#if defined(_MSC_VER) && !defined(_SIMULATION_RUNTIME_H) + #define DLLExport __declspec( dllexport ) +#else + #define DLLExport /* nothing */ +#endif + +#include "Testi2_functions.cpp" + +extern "C" { + +} + +#define NHELP 0 +#define NG 0//number of zero crossing +#define NX 1 +#define NY 0 +#define NP 0 // number of parameters +#define NO 0 // number of outputvar on topmodel +#define NI 0 // number of inputvar on topmodel +#define NR 1 // number of residuals for initialialization function +#define NEXT 0 // number of external objects +#define MAXORD 5 +#define NYSTR 0 // number of alg. string variables +#define NPSTR 0 // number of alg. string variables + +static DATA* localData = 0; +#define time localData->timeValue +extern "C" { /* adrpo: this is needed for Visual C++ compilation to work! */ + char *model_name="Testi2"; + char *model_dir=""; +} +char* state_names[1]={"$dummy"}; +char* derivative_names[1]={"der($dummy)"}; +char* algvars_names[1] = {""}; +char* input_names[1] = {""}; +char* output_names[1] = {""}; +char* param_names[1] = {""}; +char* string_alg_names[1] = {""}; +char* string_param_names[1] = {""}; + +char* state_comments[1]={""}; +char* derivative_comments[1]={""}; +char* algvars_comments[1] = {""}; +char* input_comments[1] = {""}; +char* output_comments[1] = {""}; +char* param_comments[1] = {""}; +char* string_param_comments[1] = {""}; +char* string_alg_comments[1] = {""}; + +#define $$dummy localData->states[0] +#define $DER$$dummy localData->statesDerivatives[0] + +char* getName( double* ptr) +{ + if( &$DER$$dummy == ptr ) return derivative_names[0]; + if( &$$dummy == ptr ) return state_names[0]; + return ""; +} + +static char init_fixed[NX+NX+NY+NP]={ + 1/*$dummy*/, 1/*default*/ +}; + +char var_attr[NX+NY+NP]={/*$dummy:*/1+0}; + +#define DIVISION(a,b,c) ((b != 0) ? a / b : a / division_error(b,c)) + + +int encounteredDivisionByZero = 0; +double division_error(double b,const char* division_str) +{ + if(!encounteredDivisionByZero){ + fprintf(stderr,"ERROR: Division by zero in partial equation: %s.\n",division_str); + encounteredDivisionByZero = 1; + } + return b; +} + +void setLocalData(DATA* data) +{ + localData = data; +} + +DATA* initializeDataStruc(DATA_FLAGS flags) +{ + DATA* returnData = (DATA*)malloc(sizeof(DATA)); + + if(!returnData) //error check + return 0; + + memset(returnData,0,sizeof(DATA)); + returnData->nStates = NX; + returnData->nAlgebraic = NY; + returnData->nParameters = NP; + returnData->nInputVars = NI; + returnData->nOutputVars = NO; + returnData->nZeroCrossing = NG; + returnData->nInitialResiduals = NR; + returnData->nHelpVars = NHELP; + returnData->stringVariables.nParameters = NPSTR; + returnData->stringVariables.nAlgebraic = NYSTR; + + if(flags & STATES && returnData->nStates) { + returnData->states = (double*) malloc(sizeof(double)*returnData->nStates); + returnData->oldStates = (double*) malloc(sizeof(double)*returnData->nStates); + returnData->oldStates2 = (double*) malloc(sizeof(double)*returnData->nStates); + assert(returnData->states&&returnData->oldStates&&returnData->oldStates2); + memset(returnData->states,0,sizeof(double)*returnData->nStates); + memset(returnData->oldStates,0,sizeof(double)*returnData->nStates); + memset(returnData->oldStates2,0,sizeof(double)*returnData->nStates); + } else { + returnData->states = 0; + returnData->oldStates = 0; + returnData->oldStates2 = 0; + } + + if(flags & STATESDERIVATIVES && returnData->nStates) { + returnData->statesDerivatives = (double*) malloc(sizeof(double)*returnData->nStates); + returnData->oldStatesDerivatives = (double*) malloc(sizeof(double)*returnData->nStates); + returnData->oldStatesDerivatives2 = (double*) malloc(sizeof(double)*returnData->nStates); + assert(returnData->statesDerivatives&&returnData->oldStatesDerivatives&&returnData->oldStatesDerivatives2); + memset(returnData->statesDerivatives,0,sizeof(double)*returnData->nStates); + memset(returnData->oldStatesDerivatives,0,sizeof(double)*returnData->nStates); + memset(returnData->oldStatesDerivatives2,0,sizeof(double)*returnData->nStates); + } else { + returnData->statesDerivatives = 0; + returnData->oldStatesDerivatives = 0; + returnData->oldStatesDerivatives2 = 0; + } + + if(flags & HELPVARS && returnData->nHelpVars) { + returnData->helpVars = (double*) malloc(sizeof(double)*returnData->nHelpVars); + assert(returnData->helpVars); + memset(returnData->helpVars,0,sizeof(double)*returnData->nHelpVars); + } else { + returnData->helpVars = 0; + } + + if(flags & ALGEBRAICS && returnData->nAlgebraic) { + returnData->algebraics = (double*) malloc(sizeof(double)*returnData->nAlgebraic); + returnData->oldAlgebraics = (double*) malloc(sizeof(double)*returnData->nAlgebraic); + returnData->oldAlgebraics2 = (double*) malloc(sizeof(double)*returnData->nAlgebraic); + assert(returnData->algebraics&&returnData->oldAlgebraics&&returnData->oldAlgebraics2); + memset(returnData->algebraics,0,sizeof(double)*returnData->nAlgebraic); + memset(returnData->oldAlgebraics,0,sizeof(double)*returnData->nAlgebraic); + memset(returnData->oldAlgebraics2,0,sizeof(double)*returnData->nAlgebraic); + } else { + returnData->algebraics = 0; + returnData->oldAlgebraics = 0; + returnData->oldAlgebraics2 = 0; + returnData->stringVariables.algebraics = 0; + } + + if (flags & ALGEBRAICS && returnData->stringVariables.nAlgebraic) { + returnData->stringVariables.algebraics = (char**)malloc(sizeof(char*)*returnData->stringVariables.nAlgebraic); + assert(returnData->stringVariables.algebraics); + memset(returnData->stringVariables.algebraics,0,sizeof(char*)*returnData->stringVariables.nAlgebraic); + } else { + returnData->stringVariables.algebraics=0; + } + + if(flags & PARAMETERS && returnData->nParameters) { + returnData->parameters = (double*) malloc(sizeof(double)*returnData->nParameters); + assert(returnData->parameters); + memset(returnData->parameters,0,sizeof(double)*returnData->nParameters); + } else { + returnData->parameters = 0; + } + + if (flags & PARAMETERS && returnData->stringVariables.nParameters) { + returnData->stringVariables.parameters = (char**)malloc(sizeof(char*)*returnData->stringVariables.nParameters); + assert(returnData->stringVariables.parameters); + memset(returnData->stringVariables.parameters,0,sizeof(char*)*returnData->stringVariables.nParameters); + } else { + returnData->stringVariables.parameters=0; + } + + if(flags & OUTPUTVARS && returnData->nOutputVars) { + returnData->outputVars = (double*) malloc(sizeof(double)*returnData->nOutputVars); + assert(returnData->outputVars); + memset(returnData->outputVars,0,sizeof(double)*returnData->nOutputVars); + } else { + returnData->outputVars = 0; + } + + if(flags & INPUTVARS && returnData->nInputVars) { + returnData->inputVars = (double*) malloc(sizeof(double)*returnData->nInputVars); + assert(returnData->inputVars); + memset(returnData->inputVars,0,sizeof(double)*returnData->nInputVars); + } else { + returnData->inputVars = 0; + } + + if(flags & INITIALRESIDUALS && returnData->nInitialResiduals) { + returnData->initialResiduals = (double*) malloc(sizeof(double)*returnData->nInitialResiduals); + assert(returnData->initialResiduals); + memset(returnData->initialResiduals,0,sizeof(double)*returnData->nInitialResiduals); + } else { + returnData->initialResiduals = 0; + } + + if(flags & INITFIXED) { + returnData->initFixed = init_fixed; + } else { + returnData->initFixed = 0; + } + + /* names */ + if(flags & MODELNAME) { + returnData->modelName = model_name; + } else { + returnData->modelName = 0; + } + + if(flags & STATESNAMES) { + returnData->statesNames = state_names; + } else { + returnData->statesNames = 0; + } + + if(flags & STATESDERIVATIVESNAMES) { + returnData->stateDerivativesNames = derivative_names; + } else { + returnData->stateDerivativesNames = 0; + } + + if(flags & ALGEBRAICSNAMES) { + returnData->algebraicsNames = algvars_names; + } else { + returnData->algebraicsNames = 0; + } + + if(flags & PARAMETERSNAMES) { + returnData->parametersNames = param_names; + } else { + returnData->parametersNames = 0; + } + + if(flags & INPUTNAMES) { + returnData->inputNames = input_names; + } else { + returnData->inputNames = 0; + } + + if(flags & OUTPUTNAMES) { + returnData->outputNames = output_names; + } else { + returnData->outputNames = 0; + } + + /* comments */ + if(flags & STATESCOMMENTS) { + returnData->statesComments = state_comments; + } else { + returnData->statesComments = 0; + } + + if(flags & STATESDERIVATIVESCOMMENTS) { + returnData->stateDerivativesComments = derivative_comments; + } else { + returnData->stateDerivativesComments = 0; + } + + if(flags & ALGEBRAICSCOMMENTS) { + returnData->algebraicsComments = algvars_comments; + } else { + returnData->algebraicsComments = 0; + } + + if(flags & PARAMETERSCOMMENTS) { + returnData->parametersComments = param_comments; + } else { + returnData->parametersComments = 0; + } + + if(flags & INPUTCOMMENTS) { + returnData->inputComments = input_comments; + } else { + returnData->inputComments = 0; + } + + if(flags & OUTPUTCOMMENTS) { + returnData->outputComments = output_comments; + } else { + returnData->outputComments = 0; + } + + if (flags & EXTERNALVARS) { + returnData->extObjs = (void**)malloc(sizeof(void*)*NEXT); + if (!returnData->extObjs) { + printf("error allocating external objects\n"); + exit(-2); + } + memset(returnData->extObjs,0,sizeof(void*)*NEXT); + setLocalData(returnData); /* must be set since used by constructors*/ + } + return returnData; +} + +void deInitializeDataStruc(DATA* data, DATA_FLAGS flags) +{ + if(!data) + return; + + if(flags & STATES && data->states) { + free(data->states); + data->states = 0; + } + + if(flags & STATESDERIVATIVES && data->statesDerivatives) { + free(data->statesDerivatives); + data->statesDerivatives = 0; + } + + if(flags & ALGEBRAICS && data->algebraics) { + free(data->algebraics); + data->algebraics = 0; + } + + if(flags & PARAMETERS && data->parameters) { + free(data->parameters); + data->parameters = 0; + } + + if(flags & OUTPUTVARS && data->inputVars) { + free(data->inputVars); + data->inputVars = 0; + } + + if(flags & INPUTVARS && data->outputVars) { + free(data->outputVars); + data->outputVars = 0; + } + + if(flags & INITIALRESIDUALS && data->initialResiduals){ + free(data->initialResiduals); + data->initialResiduals = 0; + } + if (flags & EXTERNALVARS && data->extObjs) { + free(data->extObjs); + data->extObjs = 0; + } +} + +int functionDAE_output() +{ + state mem_state; + mem_state = get_memory_state(); + restore_memory_state(mem_state); + return 0; +} + +int functionDAE_output2() +{ + state mem_state; + mem_state = get_memory_state(); + restore_memory_state(mem_state); + return 0; +} + +/* +*/ +int input_function() +{ + return 0; +} + +/* +*/ +int output_function() +{ + return 0; +} + +int functionDAE_res(double *t, double *x, double *xd, double *delta, long int *ires, double *rpar, long int* ipar) +{ + int i; + double temp_xd[NX]; + double* statesBackup; + double* statesDerivativesBackup; + double timeBackup; + statesBackup = localData->states; + statesDerivativesBackup = localData->statesDerivatives; + timeBackup = localData->timeValue; + localData->states = x; + for (i=0; inStates; i++) temp_xd[i]=localData->statesDerivatives[i]; + + localData->statesDerivatives = temp_xd; + localData->timeValue = *t; + + functionODE(); + /* get the difference between the temp_xd(=localData->statesDerivatives) and xd(=statesDerivativesBackup) */ + for (i=0; i < localData->nStates; i++) delta[i]=localData->statesDerivatives[i]-statesDerivativesBackup[i]; + + localData->states = statesBackup; + localData->statesDerivatives = statesDerivativesBackup; + localData->timeValue = timeBackup; + if (modelErrorCode) { + if (ires) *ires = -1; + modelErrorCode =0; + } + return 0; +} + +int function_zeroCrossing(long *neqm, double *t, double *x, long *ng, double *gout, double *rpar, long* ipar) +{ + double timeBackup; + state mem_state; + mem_state = get_memory_state(); + timeBackup = localData->timeValue; + localData->timeValue = *t; + functionODE(); + functionDAE_output(); + restore_memory_state(mem_state); + localData->timeValue = timeBackup; + return 0; +} + +int handleZeroCrossing(long index) +{ + state mem_state; + mem_state = get_memory_state(); + switch(index) { + default: break; + } + restore_memory_state(mem_state); + return 0; +} + +int function_updateDependents() +{ + state mem_state; + inUpdate=initial()?0:1; + mem_state = get_memory_state(); + $DER$$dummy = 0.0; + restore_memory_state(mem_state); + inUpdate=0; + return 0; +} + +int function_when(int i) +{ + state mem_state; + mem_state = get_memory_state(); + switch(i) { + default: break; + } + restore_memory_state(mem_state); + return 0; +} + +int functionODE() +{ + state mem_state; + mem_state = get_memory_state(); + $DER$$dummy = 0.0; + restore_memory_state(mem_state); + return 0; +} + +int initial_function() +{ + return 0; +} + +int initial_residual() +{ + int i=0; + state mem_state; + mem_state = get_memory_state(); + localData->initialResiduals[i++] = $DER$$dummy; + restore_memory_state(mem_state); + return 0; +} + +int bound_parameters() +{ + state mem_state; + mem_state = get_memory_state(); + restore_memory_state(mem_state); + return 0; +} + +int checkForDiscreteVarChanges() +{ + int needToIterate=0; + + for (long i = 0; i < localData->nHelpVars; i++) { + if (change(localData->helpVars[i])) { needToIterate=1; } + } + return needToIterate; +} diff --git a/org.simantics.modelica/Testi2.exe b/org.simantics.modelica/Testi2.exe new file mode 100644 index 00000000..a2dc0483 Binary files /dev/null and b/org.simantics.modelica/Testi2.exe differ diff --git a/org.simantics.modelica/Testi2.libs b/org.simantics.modelica/Testi2.libs new file mode 100644 index 00000000..e69de29b diff --git a/org.simantics.modelica/Testi2.makefile b/org.simantics.modelica/Testi2.makefile new file mode 100644 index 00000000..7eb07520 --- /dev/null +++ b/org.simantics.modelica/Testi2.makefile @@ -0,0 +1,13 @@ +#Makefile generated by OpenModelica + +CC=gcc +CXX=g++ +LINK=gcc -shared -export-dynamic +EXEEXT=.exe +DLLEXT=.dll +CFLAGS= -I"C:\OpenModelica1.5.0\/include" -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS} +LDFLAGS= -L"C:\OpenModelica1.5.0\/lib" -lc_runtime + +.PHONY: Testi2 +Testi2: Testi2.cpp + $(CXX) $(CFLAGS) -I. -o Testi2$(EXEEXT) Testi2.cpp -lsim $(LDFLAGS) -lf2c ${SENDDATALIBS} diff --git a/org.simantics.modelica/Testi2_functions.cpp b/org.simantics.modelica/Testi2_functions.cpp new file mode 100644 index 00000000..1e6303bf --- /dev/null +++ b/org.simantics.modelica/Testi2_functions.cpp @@ -0,0 +1,7 @@ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif diff --git a/org.simantics.modelica/Testi2_init.txt b/org.simantics.modelica/Testi2_init.txt new file mode 100644 index 00000000..0fb4f70d --- /dev/null +++ b/org.simantics.modelica/Testi2_init.txt @@ -0,0 +1,12 @@ +0.0 // start value +10.0 // stop value +0.02 // step value +0.0001 // tolerance +"dassl" // method +1 // n states +0 // n alg vars +0 //n parameters +0 // n string-parameters +0 // n string variables +0.0 // $dummy +0.0 \ No newline at end of file diff --git a/org.simantics.modelica/Testi2_res.plt b/org.simantics.modelica/Testi2_res.plt new file mode 100644 index 00000000..8d9cd836 --- /dev/null +++ b/org.simantics.modelica/Testi2_res.plt @@ -0,0 +1,1520 @@ +#Ptolemy Plot file, generated by OpenModelica +#IntervalSize=503 +TitleText: OpenModelica simulation plot +XLabel: t + +DataSet: time +0, 0 +2.220446049250313e-13, 2.220446049250313e-13 +0.02, 0.02 +0.04, 0.04 +0.06, 0.06 +0.08, 0.08 +0.1, 0.1 +0.12, 0.12 +0.14, 0.14 +0.16, 0.16 +0.18, 0.18 +0.2, 0.2 +0.22, 0.22 +0.24, 0.24 +0.26, 0.26 +0.28, 0.28 +0.3, 0.3 +0.32, 0.32 +0.34, 0.34 +0.36, 0.36 +0.3800000000000001, 0.3800000000000001 +0.4000000000000001, 0.4000000000000001 +0.4200000000000001, 0.4200000000000001 +0.4400000000000001, 0.4400000000000001 +0.4600000000000001, 0.4600000000000001 +0.4800000000000001, 0.4800000000000001 +0.5000000000000001, 0.5000000000000001 +0.5200000000000001, 0.5200000000000001 +0.5400000000000001, 0.5400000000000001 +0.5600000000000002, 0.5600000000000002 +0.5800000000000002, 0.5800000000000002 +0.6000000000000002, 0.6000000000000002 +0.6200000000000002, 0.6200000000000002 +0.6400000000000002, 0.6400000000000002 +0.6600000000000003, 0.6600000000000003 +0.6800000000000003, 0.6800000000000003 +0.7000000000000003, 0.7000000000000003 +0.7200000000000003, 0.7200000000000003 +0.7400000000000003, 0.7400000000000003 +0.7600000000000003, 0.7600000000000003 +0.7800000000000004, 0.7800000000000004 +0.8000000000000004, 0.8000000000000004 +0.8200000000000004, 0.8200000000000004 +0.8400000000000004, 0.8400000000000004 +0.8600000000000004, 0.8600000000000004 +0.8800000000000004, 0.8800000000000004 +0.9000000000000005, 0.9000000000000005 +0.9200000000000005, 0.9200000000000005 +0.9400000000000005, 0.9400000000000005 +0.9600000000000005, 0.9600000000000005 +0.9800000000000005, 0.9800000000000005 +1, 1 +1.02, 1.02 +1.04, 1.04 +1.06, 1.06 +1.080000000000001, 1.080000000000001 +1.100000000000001, 1.100000000000001 +1.120000000000001, 1.120000000000001 +1.140000000000001, 1.140000000000001 +1.160000000000001, 1.160000000000001 +1.180000000000001, 1.180000000000001 +1.200000000000001, 1.200000000000001 +1.220000000000001, 1.220000000000001 +1.240000000000001, 1.240000000000001 +1.260000000000001, 1.260000000000001 +1.280000000000001, 1.280000000000001 +1.300000000000001, 1.300000000000001 +1.320000000000001, 1.320000000000001 +1.340000000000001, 1.340000000000001 +1.360000000000001, 1.360000000000001 +1.380000000000001, 1.380000000000001 +1.400000000000001, 1.400000000000001 +1.420000000000001, 1.420000000000001 +1.440000000000001, 1.440000000000001 +1.460000000000001, 1.460000000000001 +1.480000000000001, 1.480000000000001 +1.500000000000001, 1.500000000000001 +1.520000000000001, 1.520000000000001 +1.540000000000001, 1.540000000000001 +1.560000000000001, 1.560000000000001 +1.580000000000001, 1.580000000000001 +1.600000000000001, 1.600000000000001 +1.620000000000001, 1.620000000000001 +1.640000000000001, 1.640000000000001 +1.660000000000001, 1.660000000000001 +1.680000000000001, 1.680000000000001 +1.700000000000001, 1.700000000000001 +1.720000000000001, 1.720000000000001 +1.740000000000001, 1.740000000000001 +1.760000000000001, 1.760000000000001 +1.780000000000001, 1.780000000000001 +1.800000000000001, 1.800000000000001 +1.820000000000001, 1.820000000000001 +1.840000000000001, 1.840000000000001 +1.860000000000001, 1.860000000000001 +1.880000000000001, 1.880000000000001 +1.900000000000001, 1.900000000000001 +1.920000000000001, 1.920000000000001 +1.940000000000001, 1.940000000000001 +1.960000000000001, 1.960000000000001 +1.980000000000001, 1.980000000000001 +2.000000000000001, 2.000000000000001 +2.020000000000001, 2.020000000000001 +2.040000000000001, 2.040000000000001 +2.060000000000001, 2.060000000000001 +2.080000000000001, 2.080000000000001 +2.100000000000001, 2.100000000000001 +2.120000000000001, 2.120000000000001 +2.140000000000001, 2.140000000000001 +2.160000000000001, 2.160000000000001 +2.180000000000001, 2.180000000000001 +2.200000000000002, 2.200000000000002 +2.220000000000002, 2.220000000000002 +2.240000000000002, 2.240000000000002 +2.260000000000002, 2.260000000000002 +2.280000000000002, 2.280000000000002 +2.300000000000002, 2.300000000000002 +2.320000000000002, 2.320000000000002 +2.340000000000002, 2.340000000000002 +2.360000000000002, 2.360000000000002 +2.380000000000002, 2.380000000000002 +2.400000000000002, 2.400000000000002 +2.420000000000002, 2.420000000000002 +2.440000000000002, 2.440000000000002 +2.460000000000002, 2.460000000000002 +2.480000000000002, 2.480000000000002 +2.500000000000002, 2.500000000000002 +2.520000000000002, 2.520000000000002 +2.540000000000002, 2.540000000000002 +2.560000000000002, 2.560000000000002 +2.580000000000002, 2.580000000000002 +2.600000000000002, 2.600000000000002 +2.620000000000002, 2.620000000000002 +2.640000000000002, 2.640000000000002 +2.660000000000002, 2.660000000000002 +2.680000000000002, 2.680000000000002 +2.700000000000002, 2.700000000000002 +2.720000000000002, 2.720000000000002 +2.740000000000002, 2.740000000000002 +2.760000000000002, 2.760000000000002 +2.780000000000002, 2.780000000000002 +2.800000000000002, 2.800000000000002 +2.820000000000002, 2.820000000000002 +2.840000000000002, 2.840000000000002 +2.860000000000002, 2.860000000000002 +2.880000000000002, 2.880000000000002 +2.900000000000002, 2.900000000000002 +2.920000000000002, 2.920000000000002 +2.940000000000002, 2.940000000000002 +2.960000000000002, 2.960000000000002 +2.980000000000002, 2.980000000000002 +3.000000000000002, 3.000000000000002 +3.020000000000002, 3.020000000000002 +3.040000000000002, 3.040000000000002 +3.060000000000002, 3.060000000000002 +3.080000000000002, 3.080000000000002 +3.100000000000002, 3.100000000000002 +3.120000000000002, 3.120000000000002 +3.140000000000002, 3.140000000000002 +3.160000000000002, 3.160000000000002 +3.180000000000002, 3.180000000000002 +3.200000000000002, 3.200000000000002 +3.220000000000002, 3.220000000000002 +3.240000000000002, 3.240000000000002 +3.260000000000002, 3.260000000000002 +3.280000000000002, 3.280000000000002 +3.300000000000002, 3.300000000000002 +3.320000000000003, 3.320000000000003 +3.340000000000003, 3.340000000000003 +3.360000000000003, 3.360000000000003 +3.380000000000003, 3.380000000000003 +3.400000000000003, 3.400000000000003 +3.420000000000003, 3.420000000000003 +3.440000000000003, 3.440000000000003 +3.460000000000003, 3.460000000000003 +3.480000000000003, 3.480000000000003 +3.500000000000003, 3.500000000000003 +3.520000000000003, 3.520000000000003 +3.540000000000003, 3.540000000000003 +3.560000000000003, 3.560000000000003 +3.580000000000003, 3.580000000000003 +3.600000000000003, 3.600000000000003 +3.620000000000003, 3.620000000000003 +3.640000000000003, 3.640000000000003 +3.660000000000003, 3.660000000000003 +3.680000000000003, 3.680000000000003 +3.700000000000003, 3.700000000000003 +3.720000000000003, 3.720000000000003 +3.740000000000003, 3.740000000000003 +3.760000000000003, 3.760000000000003 +3.780000000000003, 3.780000000000003 +3.800000000000003, 3.800000000000003 +3.820000000000003, 3.820000000000003 +3.840000000000003, 3.840000000000003 +3.860000000000003, 3.860000000000003 +3.880000000000003, 3.880000000000003 +3.900000000000003, 3.900000000000003 +3.920000000000003, 3.920000000000003 +3.940000000000003, 3.940000000000003 +3.960000000000003, 3.960000000000003 +3.980000000000003, 3.980000000000003 +4.000000000000003, 4.000000000000003 +4.020000000000002, 4.020000000000002 +4.040000000000002, 4.040000000000002 +4.060000000000001, 4.060000000000001 +4.080000000000001, 4.080000000000001 +4.100000000000001, 4.100000000000001 +4.12, 4.12 +4.14, 4.14 +4.159999999999999, 4.159999999999999 +4.179999999999999, 4.179999999999999 +4.199999999999998, 4.199999999999998 +4.219999999999998, 4.219999999999998 +4.239999999999998, 4.239999999999998 +4.259999999999997, 4.259999999999997 +4.279999999999997, 4.279999999999997 +4.299999999999996, 4.299999999999996 +4.319999999999996, 4.319999999999996 +4.339999999999995, 4.339999999999995 +4.359999999999995, 4.359999999999995 +4.379999999999995, 4.379999999999995 +4.399999999999994, 4.399999999999994 +4.419999999999994, 4.419999999999994 +4.439999999999993, 4.439999999999993 +4.459999999999993, 4.459999999999993 +4.479999999999992, 4.479999999999992 +4.499999999999992, 4.499999999999992 +4.519999999999992, 4.519999999999992 +4.539999999999991, 4.539999999999991 +4.559999999999991, 4.559999999999991 +4.57999999999999, 4.57999999999999 +4.59999999999999, 4.59999999999999 +4.619999999999989, 4.619999999999989 +4.639999999999989, 4.639999999999989 +4.659999999999989, 4.659999999999989 +4.679999999999988, 4.679999999999988 +4.699999999999988, 4.699999999999988 +4.719999999999987, 4.719999999999987 +4.739999999999987, 4.739999999999987 +4.759999999999986, 4.759999999999986 +4.779999999999986, 4.779999999999986 +4.799999999999986, 4.799999999999986 +4.819999999999985, 4.819999999999985 +4.839999999999985, 4.839999999999985 +4.859999999999984, 4.859999999999984 +4.879999999999984, 4.879999999999984 +4.899999999999983, 4.899999999999983 +4.919999999999983, 4.919999999999983 +4.939999999999983, 4.939999999999983 +4.959999999999982, 4.959999999999982 +4.979999999999982, 4.979999999999982 +4.999999999999981, 4.999999999999981 +5.019999999999981, 5.019999999999981 +5.03999999999998, 5.03999999999998 +5.05999999999998, 5.05999999999998 +5.07999999999998, 5.07999999999998 +5.099999999999979, 5.099999999999979 +5.119999999999979, 5.119999999999979 +5.139999999999978, 5.139999999999978 +5.159999999999978, 5.159999999999978 +5.179999999999978, 5.179999999999978 +5.199999999999977, 5.199999999999977 +5.219999999999977, 5.219999999999977 +5.239999999999976, 5.239999999999976 +5.259999999999976, 5.259999999999976 +5.279999999999975, 5.279999999999975 +5.299999999999975, 5.299999999999975 +5.319999999999975, 5.319999999999975 +5.339999999999974, 5.339999999999974 +5.359999999999974, 5.359999999999974 +5.379999999999973, 5.379999999999973 +5.399999999999973, 5.399999999999973 +5.419999999999972, 5.419999999999972 +5.439999999999972, 5.439999999999972 +5.459999999999972, 5.459999999999972 +5.479999999999971, 5.479999999999971 +5.499999999999971, 5.499999999999971 +5.51999999999997, 5.51999999999997 +5.53999999999997, 5.53999999999997 +5.559999999999969, 5.559999999999969 +5.579999999999969, 5.579999999999969 +5.599999999999969, 5.599999999999969 +5.619999999999968, 5.619999999999968 +5.639999999999968, 5.639999999999968 +5.659999999999967, 5.659999999999967 +5.679999999999967, 5.679999999999967 +5.699999999999966, 5.699999999999966 +5.719999999999966, 5.719999999999966 +5.739999999999966, 5.739999999999966 +5.759999999999965, 5.759999999999965 +5.779999999999965, 5.779999999999965 +5.799999999999964, 5.799999999999964 +5.819999999999964, 5.819999999999964 +5.839999999999963, 5.839999999999963 +5.859999999999963, 5.859999999999963 +5.879999999999963, 5.879999999999963 +5.899999999999962, 5.899999999999962 +5.919999999999962, 5.919999999999962 +5.939999999999961, 5.939999999999961 +5.959999999999961, 5.959999999999961 +5.97999999999996, 5.97999999999996 +5.99999999999996, 5.99999999999996 +6.01999999999996, 6.01999999999996 +6.039999999999959, 6.039999999999959 +6.059999999999959, 6.059999999999959 +6.079999999999958, 6.079999999999958 +6.099999999999958, 6.099999999999958 +6.119999999999957, 6.119999999999957 +6.139999999999957, 6.139999999999957 +6.159999999999957, 6.159999999999957 +6.179999999999956, 6.179999999999956 +6.199999999999956, 6.199999999999956 +6.219999999999955, 6.219999999999955 +6.239999999999955, 6.239999999999955 +6.259999999999954, 6.259999999999954 +6.279999999999954, 6.279999999999954 +6.299999999999954, 6.299999999999954 +6.319999999999953, 6.319999999999953 +6.339999999999953, 6.339999999999953 +6.359999999999952, 6.359999999999952 +6.379999999999952, 6.379999999999952 +6.399999999999952, 6.399999999999952 +6.419999999999951, 6.419999999999951 +6.439999999999951, 6.439999999999951 +6.45999999999995, 6.45999999999995 +6.47999999999995, 6.47999999999995 +6.499999999999949, 6.499999999999949 +6.519999999999949, 6.519999999999949 +6.539999999999949, 6.539999999999949 +6.559999999999948, 6.559999999999948 +6.579999999999948, 6.579999999999948 +6.599999999999947, 6.599999999999947 +6.619999999999947, 6.619999999999947 +6.639999999999946, 6.639999999999946 +6.659999999999946, 6.659999999999946 +6.679999999999946, 6.679999999999946 +6.699999999999945, 6.699999999999945 +6.719999999999945, 6.719999999999945 +6.739999999999944, 6.739999999999944 +6.759999999999944, 6.759999999999944 +6.779999999999943, 6.779999999999943 +6.799999999999943, 6.799999999999943 +6.819999999999943, 6.819999999999943 +6.839999999999942, 6.839999999999942 +6.859999999999942, 6.859999999999942 +6.879999999999941, 6.879999999999941 +6.899999999999941, 6.899999999999941 +6.91999999999994, 6.91999999999994 +6.93999999999994, 6.93999999999994 +6.95999999999994, 6.95999999999994 +6.979999999999939, 6.979999999999939 +6.999999999999939, 6.999999999999939 +7.019999999999938, 7.019999999999938 +7.039999999999938, 7.039999999999938 +7.059999999999937, 7.059999999999937 +7.079999999999937, 7.079999999999937 +7.099999999999937, 7.099999999999937 +7.119999999999936, 7.119999999999936 +7.139999999999936, 7.139999999999936 +7.159999999999935, 7.159999999999935 +7.179999999999935, 7.179999999999935 +7.199999999999934, 7.199999999999934 +7.219999999999934, 7.219999999999934 +7.239999999999934, 7.239999999999934 +7.259999999999933, 7.259999999999933 +7.279999999999933, 7.279999999999933 +7.299999999999932, 7.299999999999932 +7.319999999999932, 7.319999999999932 +7.339999999999931, 7.339999999999931 +7.359999999999931, 7.359999999999931 +7.379999999999931, 7.379999999999931 +7.39999999999993, 7.39999999999993 +7.41999999999993, 7.41999999999993 +7.439999999999929, 7.439999999999929 +7.459999999999929, 7.459999999999929 +7.479999999999928, 7.479999999999928 +7.499999999999928, 7.499999999999928 +7.519999999999928, 7.519999999999928 +7.539999999999927, 7.539999999999927 +7.559999999999927, 7.559999999999927 +7.579999999999926, 7.579999999999926 +7.599999999999926, 7.599999999999926 +7.619999999999925, 7.619999999999925 +7.639999999999925, 7.639999999999925 +7.659999999999925, 7.659999999999925 +7.679999999999924, 7.679999999999924 +7.699999999999924, 7.699999999999924 +7.719999999999923, 7.719999999999923 +7.739999999999923, 7.739999999999923 +7.759999999999923, 7.759999999999923 +7.779999999999922, 7.779999999999922 +7.799999999999922, 7.799999999999922 +7.819999999999921, 7.819999999999921 +7.839999999999921, 7.839999999999921 +7.85999999999992, 7.85999999999992 +7.87999999999992, 7.87999999999992 +7.89999999999992, 7.89999999999992 +7.919999999999919, 7.919999999999919 +7.939999999999919, 7.939999999999919 +7.959999999999918, 7.959999999999918 +7.979999999999918, 7.979999999999918 +7.999999999999917, 7.999999999999917 +8.019999999999918, 8.019999999999918 +8.039999999999917, 8.039999999999917 +8.059999999999917, 8.059999999999917 +8.079999999999917, 8.079999999999917 +8.099999999999916, 8.099999999999916 +8.119999999999916, 8.119999999999916 +8.139999999999915, 8.139999999999915 +8.159999999999915, 8.159999999999915 +8.179999999999914, 8.179999999999914 +8.199999999999914, 8.199999999999914 +8.219999999999914, 8.219999999999914 +8.239999999999913, 8.239999999999913 +8.259999999999913, 8.259999999999913 +8.279999999999912, 8.279999999999912 +8.299999999999912, 8.299999999999912 +8.319999999999911, 8.319999999999911 +8.339999999999911, 8.339999999999911 +8.359999999999911, 8.359999999999911 +8.37999999999991, 8.37999999999991 +8.39999999999991, 8.39999999999991 +8.419999999999909, 8.419999999999909 +8.439999999999909, 8.439999999999909 +8.459999999999908, 8.459999999999908 +8.479999999999908, 8.479999999999908 +8.499999999999908, 8.499999999999908 +8.519999999999907, 8.519999999999907 +8.539999999999907, 8.539999999999907 +8.559999999999906, 8.559999999999906 +8.579999999999906, 8.579999999999906 +8.599999999999905, 8.599999999999905 +8.619999999999905, 8.619999999999905 +8.639999999999905, 8.639999999999905 +8.659999999999904, 8.659999999999904 +8.679999999999904, 8.679999999999904 +8.699999999999903, 8.699999999999903 +8.719999999999903, 8.719999999999903 +8.739999999999903, 8.739999999999903 +8.759999999999902, 8.759999999999902 +8.779999999999902, 8.779999999999902 +8.799999999999901, 8.799999999999901 +8.819999999999901, 8.819999999999901 +8.8399999999999, 8.8399999999999 +8.8599999999999, 8.8599999999999 +8.8799999999999, 8.8799999999999 +8.899999999999899, 8.899999999999899 +8.919999999999899, 8.919999999999899 +8.939999999999898, 8.939999999999898 +8.959999999999898, 8.959999999999898 +8.979999999999897, 8.979999999999897 +8.999999999999897, 8.999999999999897 +9.019999999999897, 9.019999999999897 +9.039999999999896, 9.039999999999896 +9.059999999999896, 9.059999999999896 +9.079999999999895, 9.079999999999895 +9.099999999999895, 9.099999999999895 +9.119999999999894, 9.119999999999894 +9.139999999999894, 9.139999999999894 +9.159999999999894, 9.159999999999894 +9.179999999999893, 9.179999999999893 +9.199999999999893, 9.199999999999893 +9.219999999999892, 9.219999999999892 +9.239999999999892, 9.239999999999892 +9.259999999999891, 9.259999999999891 +9.279999999999891, 9.279999999999891 +9.299999999999891, 9.299999999999891 +9.31999999999989, 9.31999999999989 +9.33999999999989, 9.33999999999989 +9.359999999999889, 9.359999999999889 +9.379999999999889, 9.379999999999889 +9.399999999999888, 9.399999999999888 +9.419999999999888, 9.419999999999888 +9.439999999999888, 9.439999999999888 +9.459999999999887, 9.459999999999887 +9.479999999999887, 9.479999999999887 +9.499999999999886, 9.499999999999886 +9.519999999999886, 9.519999999999886 +9.539999999999885, 9.539999999999885 +9.559999999999885, 9.559999999999885 +9.579999999999885, 9.579999999999885 +9.599999999999884, 9.599999999999884 +9.619999999999884, 9.619999999999884 +9.639999999999883, 9.639999999999883 +9.659999999999883, 9.659999999999883 +9.679999999999882, 9.679999999999882 +9.699999999999882, 9.699999999999882 +9.719999999999882, 9.719999999999882 +9.739999999999881, 9.739999999999881 +9.759999999999881, 9.759999999999881 +9.77999999999988, 9.77999999999988 +9.79999999999988, 9.79999999999988 +9.819999999999879, 9.819999999999879 +9.839999999999879, 9.839999999999879 +9.859999999999879, 9.859999999999879 +9.879999999999878, 9.879999999999878 +9.899999999999878, 9.899999999999878 +9.919999999999877, 9.919999999999877 +9.939999999999877, 9.939999999999877 +9.959999999999877, 9.959999999999877 +9.979999999999876, 9.979999999999876 +9.999999999999876, 9.999999999999876 +10, 10 + +DataSet: $dummy +0, 0 +2.220446049250313e-13, 0 +0.02, 0 +0.04, 0 +0.06, 0 +0.08, 0 +0.1, 0 +0.12, 0 +0.14, 0 +0.16, 0 +0.18, 0 +0.2, 0 +0.22, 0 +0.24, 0 +0.26, 0 +0.28, 0 +0.3, 0 +0.32, 0 +0.34, 0 +0.36, 0 +0.3800000000000001, 0 +0.4000000000000001, 0 +0.4200000000000001, 0 +0.4400000000000001, 0 +0.4600000000000001, 0 +0.4800000000000001, 0 +0.5000000000000001, 0 +0.5200000000000001, 0 +0.5400000000000001, 0 +0.5600000000000002, 0 +0.5800000000000002, 0 +0.6000000000000002, 0 +0.6200000000000002, 0 +0.6400000000000002, 0 +0.6600000000000003, 0 +0.6800000000000003, 0 +0.7000000000000003, 0 +0.7200000000000003, 0 +0.7400000000000003, 0 +0.7600000000000003, 0 +0.7800000000000004, 0 +0.8000000000000004, 0 +0.8200000000000004, 0 +0.8400000000000004, 0 +0.8600000000000004, 0 +0.8800000000000004, 0 +0.9000000000000005, 0 +0.9200000000000005, 0 +0.9400000000000005, 0 +0.9600000000000005, 0 +0.9800000000000005, 0 +1, 0 +1.02, 0 +1.04, 0 +1.06, 0 +1.080000000000001, 0 +1.100000000000001, 0 +1.120000000000001, 0 +1.140000000000001, 0 +1.160000000000001, 0 +1.180000000000001, 0 +1.200000000000001, 0 +1.220000000000001, 0 +1.240000000000001, 0 +1.260000000000001, 0 +1.280000000000001, 0 +1.300000000000001, 0 +1.320000000000001, 0 +1.340000000000001, 0 +1.360000000000001, 0 +1.380000000000001, 0 +1.400000000000001, 0 +1.420000000000001, 0 +1.440000000000001, 0 +1.460000000000001, 0 +1.480000000000001, 0 +1.500000000000001, 0 +1.520000000000001, 0 +1.540000000000001, 0 +1.560000000000001, 0 +1.580000000000001, 0 +1.600000000000001, 0 +1.620000000000001, 0 +1.640000000000001, 0 +1.660000000000001, 0 +1.680000000000001, 0 +1.700000000000001, 0 +1.720000000000001, 0 +1.740000000000001, 0 +1.760000000000001, 0 +1.780000000000001, 0 +1.800000000000001, 0 +1.820000000000001, 0 +1.840000000000001, 0 +1.860000000000001, 0 +1.880000000000001, 0 +1.900000000000001, 0 +1.920000000000001, 0 +1.940000000000001, 0 +1.960000000000001, 0 +1.980000000000001, 0 +2.000000000000001, 0 +2.020000000000001, 0 +2.040000000000001, 0 +2.060000000000001, 0 +2.080000000000001, 0 +2.100000000000001, 0 +2.120000000000001, 0 +2.140000000000001, 0 +2.160000000000001, 0 +2.180000000000001, 0 +2.200000000000002, 0 +2.220000000000002, 0 +2.240000000000002, 0 +2.260000000000002, 0 +2.280000000000002, 0 +2.300000000000002, 0 +2.320000000000002, 0 +2.340000000000002, 0 +2.360000000000002, 0 +2.380000000000002, 0 +2.400000000000002, 0 +2.420000000000002, 0 +2.440000000000002, 0 +2.460000000000002, 0 +2.480000000000002, 0 +2.500000000000002, 0 +2.520000000000002, 0 +2.540000000000002, 0 +2.560000000000002, 0 +2.580000000000002, 0 +2.600000000000002, 0 +2.620000000000002, 0 +2.640000000000002, 0 +2.660000000000002, 0 +2.680000000000002, 0 +2.700000000000002, 0 +2.720000000000002, 0 +2.740000000000002, 0 +2.760000000000002, 0 +2.780000000000002, 0 +2.800000000000002, 0 +2.820000000000002, 0 +2.840000000000002, 0 +2.860000000000002, 0 +2.880000000000002, 0 +2.900000000000002, 0 +2.920000000000002, 0 +2.940000000000002, 0 +2.960000000000002, 0 +2.980000000000002, 0 +3.000000000000002, 0 +3.020000000000002, 0 +3.040000000000002, 0 +3.060000000000002, 0 +3.080000000000002, 0 +3.100000000000002, 0 +3.120000000000002, 0 +3.140000000000002, 0 +3.160000000000002, 0 +3.180000000000002, 0 +3.200000000000002, 0 +3.220000000000002, 0 +3.240000000000002, 0 +3.260000000000002, 0 +3.280000000000002, 0 +3.300000000000002, 0 +3.320000000000003, 0 +3.340000000000003, 0 +3.360000000000003, 0 +3.380000000000003, 0 +3.400000000000003, 0 +3.420000000000003, 0 +3.440000000000003, 0 +3.460000000000003, 0 +3.480000000000003, 0 +3.500000000000003, 0 +3.520000000000003, 0 +3.540000000000003, 0 +3.560000000000003, 0 +3.580000000000003, 0 +3.600000000000003, 0 +3.620000000000003, 0 +3.640000000000003, 0 +3.660000000000003, 0 +3.680000000000003, 0 +3.700000000000003, 0 +3.720000000000003, 0 +3.740000000000003, 0 +3.760000000000003, 0 +3.780000000000003, 0 +3.800000000000003, 0 +3.820000000000003, 0 +3.840000000000003, 0 +3.860000000000003, 0 +3.880000000000003, 0 +3.900000000000003, 0 +3.920000000000003, 0 +3.940000000000003, 0 +3.960000000000003, 0 +3.980000000000003, 0 +4.000000000000003, 0 +4.020000000000002, 0 +4.040000000000002, 0 +4.060000000000001, 0 +4.080000000000001, 0 +4.100000000000001, 0 +4.12, 0 +4.14, 0 +4.159999999999999, 0 +4.179999999999999, 0 +4.199999999999998, 0 +4.219999999999998, 0 +4.239999999999998, 0 +4.259999999999997, 0 +4.279999999999997, 0 +4.299999999999996, 0 +4.319999999999996, 0 +4.339999999999995, 0 +4.359999999999995, 0 +4.379999999999995, 0 +4.399999999999994, 0 +4.419999999999994, 0 +4.439999999999993, 0 +4.459999999999993, 0 +4.479999999999992, 0 +4.499999999999992, 0 +4.519999999999992, 0 +4.539999999999991, 0 +4.559999999999991, 0 +4.57999999999999, 0 +4.59999999999999, 0 +4.619999999999989, 0 +4.639999999999989, 0 +4.659999999999989, 0 +4.679999999999988, 0 +4.699999999999988, 0 +4.719999999999987, 0 +4.739999999999987, 0 +4.759999999999986, 0 +4.779999999999986, 0 +4.799999999999986, 0 +4.819999999999985, 0 +4.839999999999985, 0 +4.859999999999984, 0 +4.879999999999984, 0 +4.899999999999983, 0 +4.919999999999983, 0 +4.939999999999983, 0 +4.959999999999982, 0 +4.979999999999982, 0 +4.999999999999981, 0 +5.019999999999981, 0 +5.03999999999998, 0 +5.05999999999998, 0 +5.07999999999998, 0 +5.099999999999979, 0 +5.119999999999979, 0 +5.139999999999978, 0 +5.159999999999978, 0 +5.179999999999978, 0 +5.199999999999977, 0 +5.219999999999977, 0 +5.239999999999976, 0 +5.259999999999976, 0 +5.279999999999975, 0 +5.299999999999975, 0 +5.319999999999975, 0 +5.339999999999974, 0 +5.359999999999974, 0 +5.379999999999973, 0 +5.399999999999973, 0 +5.419999999999972, 0 +5.439999999999972, 0 +5.459999999999972, 0 +5.479999999999971, 0 +5.499999999999971, 0 +5.51999999999997, 0 +5.53999999999997, 0 +5.559999999999969, 0 +5.579999999999969, 0 +5.599999999999969, 0 +5.619999999999968, 0 +5.639999999999968, 0 +5.659999999999967, 0 +5.679999999999967, 0 +5.699999999999966, 0 +5.719999999999966, 0 +5.739999999999966, 0 +5.759999999999965, 0 +5.779999999999965, 0 +5.799999999999964, 0 +5.819999999999964, 0 +5.839999999999963, 0 +5.859999999999963, 0 +5.879999999999963, 0 +5.899999999999962, 0 +5.919999999999962, 0 +5.939999999999961, 0 +5.959999999999961, 0 +5.97999999999996, 0 +5.99999999999996, 0 +6.01999999999996, 0 +6.039999999999959, 0 +6.059999999999959, 0 +6.079999999999958, 0 +6.099999999999958, 0 +6.119999999999957, 0 +6.139999999999957, 0 +6.159999999999957, 0 +6.179999999999956, 0 +6.199999999999956, 0 +6.219999999999955, 0 +6.239999999999955, 0 +6.259999999999954, 0 +6.279999999999954, 0 +6.299999999999954, 0 +6.319999999999953, 0 +6.339999999999953, 0 +6.359999999999952, 0 +6.379999999999952, 0 +6.399999999999952, 0 +6.419999999999951, 0 +6.439999999999951, 0 +6.45999999999995, 0 +6.47999999999995, 0 +6.499999999999949, 0 +6.519999999999949, 0 +6.539999999999949, 0 +6.559999999999948, 0 +6.579999999999948, 0 +6.599999999999947, 0 +6.619999999999947, 0 +6.639999999999946, 0 +6.659999999999946, 0 +6.679999999999946, 0 +6.699999999999945, 0 +6.719999999999945, 0 +6.739999999999944, 0 +6.759999999999944, 0 +6.779999999999943, 0 +6.799999999999943, 0 +6.819999999999943, 0 +6.839999999999942, 0 +6.859999999999942, 0 +6.879999999999941, 0 +6.899999999999941, 0 +6.91999999999994, 0 +6.93999999999994, 0 +6.95999999999994, 0 +6.979999999999939, 0 +6.999999999999939, 0 +7.019999999999938, 0 +7.039999999999938, 0 +7.059999999999937, 0 +7.079999999999937, 0 +7.099999999999937, 0 +7.119999999999936, 0 +7.139999999999936, 0 +7.159999999999935, 0 +7.179999999999935, 0 +7.199999999999934, 0 +7.219999999999934, 0 +7.239999999999934, 0 +7.259999999999933, 0 +7.279999999999933, 0 +7.299999999999932, 0 +7.319999999999932, 0 +7.339999999999931, 0 +7.359999999999931, 0 +7.379999999999931, 0 +7.39999999999993, 0 +7.41999999999993, 0 +7.439999999999929, 0 +7.459999999999929, 0 +7.479999999999928, 0 +7.499999999999928, 0 +7.519999999999928, 0 +7.539999999999927, 0 +7.559999999999927, 0 +7.579999999999926, 0 +7.599999999999926, 0 +7.619999999999925, 0 +7.639999999999925, 0 +7.659999999999925, 0 +7.679999999999924, 0 +7.699999999999924, 0 +7.719999999999923, 0 +7.739999999999923, 0 +7.759999999999923, 0 +7.779999999999922, 0 +7.799999999999922, 0 +7.819999999999921, 0 +7.839999999999921, 0 +7.85999999999992, 0 +7.87999999999992, 0 +7.89999999999992, 0 +7.919999999999919, 0 +7.939999999999919, 0 +7.959999999999918, 0 +7.979999999999918, 0 +7.999999999999917, 0 +8.019999999999918, 0 +8.039999999999917, 0 +8.059999999999917, 0 +8.079999999999917, 0 +8.099999999999916, 0 +8.119999999999916, 0 +8.139999999999915, 0 +8.159999999999915, 0 +8.179999999999914, 0 +8.199999999999914, 0 +8.219999999999914, 0 +8.239999999999913, 0 +8.259999999999913, 0 +8.279999999999912, 0 +8.299999999999912, 0 +8.319999999999911, 0 +8.339999999999911, 0 +8.359999999999911, 0 +8.37999999999991, 0 +8.39999999999991, 0 +8.419999999999909, 0 +8.439999999999909, 0 +8.459999999999908, 0 +8.479999999999908, 0 +8.499999999999908, 0 +8.519999999999907, 0 +8.539999999999907, 0 +8.559999999999906, 0 +8.579999999999906, 0 +8.599999999999905, 0 +8.619999999999905, 0 +8.639999999999905, 0 +8.659999999999904, 0 +8.679999999999904, 0 +8.699999999999903, 0 +8.719999999999903, 0 +8.739999999999903, 0 +8.759999999999902, 0 +8.779999999999902, 0 +8.799999999999901, 0 +8.819999999999901, 0 +8.8399999999999, 0 +8.8599999999999, 0 +8.8799999999999, 0 +8.899999999999899, 0 +8.919999999999899, 0 +8.939999999999898, 0 +8.959999999999898, 0 +8.979999999999897, 0 +8.999999999999897, 0 +9.019999999999897, 0 +9.039999999999896, 0 +9.059999999999896, 0 +9.079999999999895, 0 +9.099999999999895, 0 +9.119999999999894, 0 +9.139999999999894, 0 +9.159999999999894, 0 +9.179999999999893, 0 +9.199999999999893, 0 +9.219999999999892, 0 +9.239999999999892, 0 +9.259999999999891, 0 +9.279999999999891, 0 +9.299999999999891, 0 +9.31999999999989, 0 +9.33999999999989, 0 +9.359999999999889, 0 +9.379999999999889, 0 +9.399999999999888, 0 +9.419999999999888, 0 +9.439999999999888, 0 +9.459999999999887, 0 +9.479999999999887, 0 +9.499999999999886, 0 +9.519999999999886, 0 +9.539999999999885, 0 +9.559999999999885, 0 +9.579999999999885, 0 +9.599999999999884, 0 +9.619999999999884, 0 +9.639999999999883, 0 +9.659999999999883, 0 +9.679999999999882, 0 +9.699999999999882, 0 +9.719999999999882, 0 +9.739999999999881, 0 +9.759999999999881, 0 +9.77999999999988, 0 +9.79999999999988, 0 +9.819999999999879, 0 +9.839999999999879, 0 +9.859999999999879, 0 +9.879999999999878, 0 +9.899999999999878, 0 +9.919999999999877, 0 +9.939999999999877, 0 +9.959999999999877, 0 +9.979999999999876, 0 +9.999999999999876, 0 +10, 0 + +DataSet: der($dummy) +0, 0 +2.220446049250313e-13, 0 +0.02, 0 +0.04, 0 +0.06, 0 +0.08, 0 +0.1, 0 +0.12, 0 +0.14, 0 +0.16, 0 +0.18, 0 +0.2, 0 +0.22, 0 +0.24, 0 +0.26, 0 +0.28, 0 +0.3, 0 +0.32, 0 +0.34, 0 +0.36, 0 +0.3800000000000001, 0 +0.4000000000000001, 0 +0.4200000000000001, 0 +0.4400000000000001, 0 +0.4600000000000001, 0 +0.4800000000000001, 0 +0.5000000000000001, 0 +0.5200000000000001, 0 +0.5400000000000001, 0 +0.5600000000000002, 0 +0.5800000000000002, 0 +0.6000000000000002, 0 +0.6200000000000002, 0 +0.6400000000000002, 0 +0.6600000000000003, 0 +0.6800000000000003, 0 +0.7000000000000003, 0 +0.7200000000000003, 0 +0.7400000000000003, 0 +0.7600000000000003, 0 +0.7800000000000004, 0 +0.8000000000000004, 0 +0.8200000000000004, 0 +0.8400000000000004, 0 +0.8600000000000004, 0 +0.8800000000000004, 0 +0.9000000000000005, 0 +0.9200000000000005, 0 +0.9400000000000005, 0 +0.9600000000000005, 0 +0.9800000000000005, 0 +1, 0 +1.02, 0 +1.04, 0 +1.06, 0 +1.080000000000001, 0 +1.100000000000001, 0 +1.120000000000001, 0 +1.140000000000001, 0 +1.160000000000001, 0 +1.180000000000001, 0 +1.200000000000001, 0 +1.220000000000001, 0 +1.240000000000001, 0 +1.260000000000001, 0 +1.280000000000001, 0 +1.300000000000001, 0 +1.320000000000001, 0 +1.340000000000001, 0 +1.360000000000001, 0 +1.380000000000001, 0 +1.400000000000001, 0 +1.420000000000001, 0 +1.440000000000001, 0 +1.460000000000001, 0 +1.480000000000001, 0 +1.500000000000001, 0 +1.520000000000001, 0 +1.540000000000001, 0 +1.560000000000001, 0 +1.580000000000001, 0 +1.600000000000001, 0 +1.620000000000001, 0 +1.640000000000001, 0 +1.660000000000001, 0 +1.680000000000001, 0 +1.700000000000001, 0 +1.720000000000001, 0 +1.740000000000001, 0 +1.760000000000001, 0 +1.780000000000001, 0 +1.800000000000001, 0 +1.820000000000001, 0 +1.840000000000001, 0 +1.860000000000001, 0 +1.880000000000001, 0 +1.900000000000001, 0 +1.920000000000001, 0 +1.940000000000001, 0 +1.960000000000001, 0 +1.980000000000001, 0 +2.000000000000001, 0 +2.020000000000001, 0 +2.040000000000001, 0 +2.060000000000001, 0 +2.080000000000001, 0 +2.100000000000001, 0 +2.120000000000001, 0 +2.140000000000001, 0 +2.160000000000001, 0 +2.180000000000001, 0 +2.200000000000002, 0 +2.220000000000002, 0 +2.240000000000002, 0 +2.260000000000002, 0 +2.280000000000002, 0 +2.300000000000002, 0 +2.320000000000002, 0 +2.340000000000002, 0 +2.360000000000002, 0 +2.380000000000002, 0 +2.400000000000002, 0 +2.420000000000002, 0 +2.440000000000002, 0 +2.460000000000002, 0 +2.480000000000002, 0 +2.500000000000002, 0 +2.520000000000002, 0 +2.540000000000002, 0 +2.560000000000002, 0 +2.580000000000002, 0 +2.600000000000002, 0 +2.620000000000002, 0 +2.640000000000002, 0 +2.660000000000002, 0 +2.680000000000002, 0 +2.700000000000002, 0 +2.720000000000002, 0 +2.740000000000002, 0 +2.760000000000002, 0 +2.780000000000002, 0 +2.800000000000002, 0 +2.820000000000002, 0 +2.840000000000002, 0 +2.860000000000002, 0 +2.880000000000002, 0 +2.900000000000002, 0 +2.920000000000002, 0 +2.940000000000002, 0 +2.960000000000002, 0 +2.980000000000002, 0 +3.000000000000002, 0 +3.020000000000002, 0 +3.040000000000002, 0 +3.060000000000002, 0 +3.080000000000002, 0 +3.100000000000002, 0 +3.120000000000002, 0 +3.140000000000002, 0 +3.160000000000002, 0 +3.180000000000002, 0 +3.200000000000002, 0 +3.220000000000002, 0 +3.240000000000002, 0 +3.260000000000002, 0 +3.280000000000002, 0 +3.300000000000002, 0 +3.320000000000003, 0 +3.340000000000003, 0 +3.360000000000003, 0 +3.380000000000003, 0 +3.400000000000003, 0 +3.420000000000003, 0 +3.440000000000003, 0 +3.460000000000003, 0 +3.480000000000003, 0 +3.500000000000003, 0 +3.520000000000003, 0 +3.540000000000003, 0 +3.560000000000003, 0 +3.580000000000003, 0 +3.600000000000003, 0 +3.620000000000003, 0 +3.640000000000003, 0 +3.660000000000003, 0 +3.680000000000003, 0 +3.700000000000003, 0 +3.720000000000003, 0 +3.740000000000003, 0 +3.760000000000003, 0 +3.780000000000003, 0 +3.800000000000003, 0 +3.820000000000003, 0 +3.840000000000003, 0 +3.860000000000003, 0 +3.880000000000003, 0 +3.900000000000003, 0 +3.920000000000003, 0 +3.940000000000003, 0 +3.960000000000003, 0 +3.980000000000003, 0 +4.000000000000003, 0 +4.020000000000002, 0 +4.040000000000002, 0 +4.060000000000001, 0 +4.080000000000001, 0 +4.100000000000001, 0 +4.12, 0 +4.14, 0 +4.159999999999999, 0 +4.179999999999999, 0 +4.199999999999998, 0 +4.219999999999998, 0 +4.239999999999998, 0 +4.259999999999997, 0 +4.279999999999997, 0 +4.299999999999996, 0 +4.319999999999996, 0 +4.339999999999995, 0 +4.359999999999995, 0 +4.379999999999995, 0 +4.399999999999994, 0 +4.419999999999994, 0 +4.439999999999993, 0 +4.459999999999993, 0 +4.479999999999992, 0 +4.499999999999992, 0 +4.519999999999992, 0 +4.539999999999991, 0 +4.559999999999991, 0 +4.57999999999999, 0 +4.59999999999999, 0 +4.619999999999989, 0 +4.639999999999989, 0 +4.659999999999989, 0 +4.679999999999988, 0 +4.699999999999988, 0 +4.719999999999987, 0 +4.739999999999987, 0 +4.759999999999986, 0 +4.779999999999986, 0 +4.799999999999986, 0 +4.819999999999985, 0 +4.839999999999985, 0 +4.859999999999984, 0 +4.879999999999984, 0 +4.899999999999983, 0 +4.919999999999983, 0 +4.939999999999983, 0 +4.959999999999982, 0 +4.979999999999982, 0 +4.999999999999981, 0 +5.019999999999981, 0 +5.03999999999998, 0 +5.05999999999998, 0 +5.07999999999998, 0 +5.099999999999979, 0 +5.119999999999979, 0 +5.139999999999978, 0 +5.159999999999978, 0 +5.179999999999978, 0 +5.199999999999977, 0 +5.219999999999977, 0 +5.239999999999976, 0 +5.259999999999976, 0 +5.279999999999975, 0 +5.299999999999975, 0 +5.319999999999975, 0 +5.339999999999974, 0 +5.359999999999974, 0 +5.379999999999973, 0 +5.399999999999973, 0 +5.419999999999972, 0 +5.439999999999972, 0 +5.459999999999972, 0 +5.479999999999971, 0 +5.499999999999971, 0 +5.51999999999997, 0 +5.53999999999997, 0 +5.559999999999969, 0 +5.579999999999969, 0 +5.599999999999969, 0 +5.619999999999968, 0 +5.639999999999968, 0 +5.659999999999967, 0 +5.679999999999967, 0 +5.699999999999966, 0 +5.719999999999966, 0 +5.739999999999966, 0 +5.759999999999965, 0 +5.779999999999965, 0 +5.799999999999964, 0 +5.819999999999964, 0 +5.839999999999963, 0 +5.859999999999963, 0 +5.879999999999963, 0 +5.899999999999962, 0 +5.919999999999962, 0 +5.939999999999961, 0 +5.959999999999961, 0 +5.97999999999996, 0 +5.99999999999996, 0 +6.01999999999996, 0 +6.039999999999959, 0 +6.059999999999959, 0 +6.079999999999958, 0 +6.099999999999958, 0 +6.119999999999957, 0 +6.139999999999957, 0 +6.159999999999957, 0 +6.179999999999956, 0 +6.199999999999956, 0 +6.219999999999955, 0 +6.239999999999955, 0 +6.259999999999954, 0 +6.279999999999954, 0 +6.299999999999954, 0 +6.319999999999953, 0 +6.339999999999953, 0 +6.359999999999952, 0 +6.379999999999952, 0 +6.399999999999952, 0 +6.419999999999951, 0 +6.439999999999951, 0 +6.45999999999995, 0 +6.47999999999995, 0 +6.499999999999949, 0 +6.519999999999949, 0 +6.539999999999949, 0 +6.559999999999948, 0 +6.579999999999948, 0 +6.599999999999947, 0 +6.619999999999947, 0 +6.639999999999946, 0 +6.659999999999946, 0 +6.679999999999946, 0 +6.699999999999945, 0 +6.719999999999945, 0 +6.739999999999944, 0 +6.759999999999944, 0 +6.779999999999943, 0 +6.799999999999943, 0 +6.819999999999943, 0 +6.839999999999942, 0 +6.859999999999942, 0 +6.879999999999941, 0 +6.899999999999941, 0 +6.91999999999994, 0 +6.93999999999994, 0 +6.95999999999994, 0 +6.979999999999939, 0 +6.999999999999939, 0 +7.019999999999938, 0 +7.039999999999938, 0 +7.059999999999937, 0 +7.079999999999937, 0 +7.099999999999937, 0 +7.119999999999936, 0 +7.139999999999936, 0 +7.159999999999935, 0 +7.179999999999935, 0 +7.199999999999934, 0 +7.219999999999934, 0 +7.239999999999934, 0 +7.259999999999933, 0 +7.279999999999933, 0 +7.299999999999932, 0 +7.319999999999932, 0 +7.339999999999931, 0 +7.359999999999931, 0 +7.379999999999931, 0 +7.39999999999993, 0 +7.41999999999993, 0 +7.439999999999929, 0 +7.459999999999929, 0 +7.479999999999928, 0 +7.499999999999928, 0 +7.519999999999928, 0 +7.539999999999927, 0 +7.559999999999927, 0 +7.579999999999926, 0 +7.599999999999926, 0 +7.619999999999925, 0 +7.639999999999925, 0 +7.659999999999925, 0 +7.679999999999924, 0 +7.699999999999924, 0 +7.719999999999923, 0 +7.739999999999923, 0 +7.759999999999923, 0 +7.779999999999922, 0 +7.799999999999922, 0 +7.819999999999921, 0 +7.839999999999921, 0 +7.85999999999992, 0 +7.87999999999992, 0 +7.89999999999992, 0 +7.919999999999919, 0 +7.939999999999919, 0 +7.959999999999918, 0 +7.979999999999918, 0 +7.999999999999917, 0 +8.019999999999918, 0 +8.039999999999917, 0 +8.059999999999917, 0 +8.079999999999917, 0 +8.099999999999916, 0 +8.119999999999916, 0 +8.139999999999915, 0 +8.159999999999915, 0 +8.179999999999914, 0 +8.199999999999914, 0 +8.219999999999914, 0 +8.239999999999913, 0 +8.259999999999913, 0 +8.279999999999912, 0 +8.299999999999912, 0 +8.319999999999911, 0 +8.339999999999911, 0 +8.359999999999911, 0 +8.37999999999991, 0 +8.39999999999991, 0 +8.419999999999909, 0 +8.439999999999909, 0 +8.459999999999908, 0 +8.479999999999908, 0 +8.499999999999908, 0 +8.519999999999907, 0 +8.539999999999907, 0 +8.559999999999906, 0 +8.579999999999906, 0 +8.599999999999905, 0 +8.619999999999905, 0 +8.639999999999905, 0 +8.659999999999904, 0 +8.679999999999904, 0 +8.699999999999903, 0 +8.719999999999903, 0 +8.739999999999903, 0 +8.759999999999902, 0 +8.779999999999902, 0 +8.799999999999901, 0 +8.819999999999901, 0 +8.8399999999999, 0 +8.8599999999999, 0 +8.8799999999999, 0 +8.899999999999899, 0 +8.919999999999899, 0 +8.939999999999898, 0 +8.959999999999898, 0 +8.979999999999897, 0 +8.999999999999897, 0 +9.019999999999897, 0 +9.039999999999896, 0 +9.059999999999896, 0 +9.079999999999895, 0 +9.099999999999895, 0 +9.119999999999894, 0 +9.139999999999894, 0 +9.159999999999894, 0 +9.179999999999893, 0 +9.199999999999893, 0 +9.219999999999892, 0 +9.239999999999892, 0 +9.259999999999891, 0 +9.279999999999891, 0 +9.299999999999891, 0 +9.31999999999989, 0 +9.33999999999989, 0 +9.359999999999889, 0 +9.379999999999889, 0 +9.399999999999888, 0 +9.419999999999888, 0 +9.439999999999888, 0 +9.459999999999887, 0 +9.479999999999887, 0 +9.499999999999886, 0 +9.519999999999886, 0 +9.539999999999885, 0 +9.559999999999885, 0 +9.579999999999885, 0 +9.599999999999884, 0 +9.619999999999884, 0 +9.639999999999883, 0 +9.659999999999883, 0 +9.679999999999882, 0 +9.699999999999882, 0 +9.719999999999882, 0 +9.739999999999881, 0 +9.759999999999881, 0 +9.77999999999988, 0 +9.79999999999988, 0 +9.819999999999879, 0 +9.839999999999879, 0 +9.859999999999879, 0 +9.879999999999878, 0 +9.899999999999878, 0 +9.919999999999877, 0 +9.939999999999877, 0 +9.959999999999877, 0 +9.979999999999876, 0 +9.999999999999876, 0 +10, 0 + diff --git a/org.simantics.modelica/build.properties b/org.simantics.modelica/build.properties new file mode 100644 index 00000000..41eb6ade --- /dev/null +++ b/org.simantics.modelica/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/org.simantics.modelica/src/org/simantics/modelica/ModelicaManager.java b/org.simantics.modelica/src/org/simantics/modelica/ModelicaManager.java new file mode 100644 index 00000000..419b1ee6 --- /dev/null +++ b/org.simantics.modelica/src/org/simantics/modelica/ModelicaManager.java @@ -0,0 +1,140 @@ +package org.simantics.modelica; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; + +import org.simantics.modelica.data.DataSet; +import org.simantics.modelica.data.SimulationResult; + +public class ModelicaManager { + + protected static File getOpenModelicaHome() { + String dir = System.getenv("OPENMODELICAHOMEe"); + if(dir == null) + dir = "c:/OpenModelica1.5.0"; + return new File(dir); + } + + protected static File createTempDirectory() throws IOException { + final File temp = File.createTempFile("temp", Long.toString(System.nanoTime())); + if(!(temp.delete())) + throw new IOException("Could not delete temp file: " + temp.getAbsolutePath()); + if(!(temp.mkdir())) + throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); + return (temp); + } + + protected static boolean recursiveDelete(File fileOrDir) { + if(fileOrDir.isDirectory()) + for(File innerFile: fileOrDir.listFiles()) + if(!recursiveDelete(innerFile)) + return false; + return fileOrDir.delete(); + } + + protected static String readFile(File file) throws IOException { + InputStream stream = new FileInputStream(file); + byte[] buffer = new byte[(int)file.length()]; + stream.read(buffer); + stream.close(); + return new String(buffer); + } + + protected static void printProcessOutput(Process process) throws IOException { + InputStream stream = process.getInputStream(); + while(true) { + int c = stream.read(); + if(c <= 0) + break; + System.out.print((char)c); + } + } + + static class SimulationLocation { + File simulationDir; + File inputFile; + File outputFile; + + public SimulationLocation(File simulationDir, File inputFile, + File outputFile) { + this.simulationDir = simulationDir; + this.inputFile = inputFile; + this.outputFile = outputFile; + } + } + + protected static SimulationLocation createInputFiles(String modelName, String modelText) throws IOException { + File simulationDir = createTempDirectory(); + File modelFile = new File(simulationDir, modelName + ".mo"); + File scriptFile = new File(simulationDir, modelName + ".mos"); + + { + PrintStream s = new PrintStream(modelFile); + s.print(modelText); + s.close(); + } + + { + PrintStream s = new PrintStream(scriptFile); + s.println("loadFile(\"" + modelName + ".mo\");"); + s.println("simulate("+modelName+ + ",startTime="+0.0+ + ",stopTime="+10.0+ + ");"); + s.close(); + } + + return new SimulationLocation( + simulationDir, + new File(simulationDir, modelName + ".mos"), + new File(simulationDir, modelName + "_res.plt") + ); + } + + public static SimulationResult runModelica(String modelName, String modelText) throws IOException { + SimulationLocation simulationLocation = + createInputFiles(modelName, modelText); + + try { + File modelicaHome = getOpenModelicaHome(); + File omc = new File(modelicaHome, "bin/omc.exe"); + + Process process = new ProcessBuilder( + omc.getAbsolutePath(), + simulationLocation.inputFile.getAbsolutePath() + ) + .directory(simulationLocation.simulationDir.getAbsoluteFile()) + .redirectErrorStream(true) + .start(); + printProcessOutput(process); + + SimulationResult result = new SimulationResult(); + result.read(simulationLocation.outputFile); + + result.filter(); + + for(DataSet set : result.getDataSets()) + System.out.println(set.name); + + return result; + } catch(IOException e) { + e.printStackTrace(); + } finally { + recursiveDelete(simulationLocation.simulationDir); + } + return null; + } + + public static void main(String[] args) { + try { + runModelica("Testi2", "model Testi2 end Testi2;"); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/org.simantics.modelica/src/org/simantics/modelica/data/DataSet.java b/org.simantics.modelica/src/org/simantics/modelica/data/DataSet.java new file mode 100644 index 00000000..4f024907 --- /dev/null +++ b/org.simantics.modelica/src/org/simantics/modelica/data/DataSet.java @@ -0,0 +1,17 @@ +package org.simantics.modelica.data; + +/** + * Simulation result for one variable. + * @author Hannu Niemistö + */ +public class DataSet { + public String name; + public double[] times; + public double[] values; + + public DataSet(String name, double[] times, double[] values) { + this.name = name; + this.times = times; + this.values = values; + } +} diff --git a/org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java b/org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java new file mode 100644 index 00000000..0676555b --- /dev/null +++ b/org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java @@ -0,0 +1,105 @@ +package org.simantics.modelica.data; + +import gnu.trove.TDoubleArrayList; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Class that reads OpenModelica result files. + * @author Hannu Niemistö + */ +public class SimulationResult { + + List dataSets = new ArrayList(); + + static String getLine(InputStream stream) { + if(stream == null) + return null; + StringBuilder b = new StringBuilder(); + try { + while(true) { + int c = stream.read(); + if(c == -1) { + stream = null; + return b.toString(); + } + else if(c == '\n') + return b.toString(); + else if(c == '\r') + ; + else + b.append((char)c); + } + } catch (IOException e) { + return null; + } + + } + + final static Pattern p1 = Pattern.compile("DataSet: ([^ ]*)"); + + public void read(File file) throws FileNotFoundException { + read(new FileInputStream(file)); + } + + public void read(InputStream stream) { + while(true) { + String line = getLine(stream); + if(line == null) + return; + if(line.isEmpty()) + break; + } + + // Data sets + while(true) { + Matcher matcher = p1.matcher(getLine(stream)); + if(!matcher.matches()) + return; + String name = matcher.group(1); + + TDoubleArrayList times = new TDoubleArrayList(); + TDoubleArrayList values = new TDoubleArrayList(); + while(true) { + String line = getLine(stream); + if(line == null) + return; + if(line.isEmpty()) + break; + String[] nn = line.split(", ", 2); + times.add(Double.parseDouble(nn[0])); + values.add(Double.parseDouble(nn[1])); + } + + dataSets.add(new DataSet(name, times.toNativeArray(), values.toNativeArray())); + } + } + + public void filter() { + ArrayList newDataSets = new ArrayList(); + for(DataSet dataSet : dataSets) { + if(!dataSet.name.equals("time") && !dataSet.name.contains("$") && !dataSet.name.contains("der(")) + newDataSets.add(dataSet); + } + dataSets = newDataSets; + } + + public List getDataSets() { + return dataSets; + } + + public DataSet getDataSet(String name) { + for(DataSet set : dataSets) + if(set.name.equals(name)) + return set; + return null; + } +}