Changeset 15372
- Timestamp:
- 2013-02-27T18:35:22+01:00 (11 years ago)
- Location:
- trunk/SimulationRuntime/c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SimulationRuntime/c/simulation/simulation_runtime.cpp
r15356 r15372 340 340 string tmp = ("^(" + varfilter + ")$"); 341 341 const char *filter = tmp.c_str(); // C++ strings are horrible to work with... 342 if(modelData->nStates > 0 && 0 == strcmp(modelData->realVarsData[0].info.name, "$dummy")) {342 if(modelData->nStates > 0 && 0 == strcmp(modelData->realVarsData[0].info.name, "$dummy")) { 343 343 modelData->realVarsData[0].filterOutput = 1; 344 344 modelData->realVarsData[modelData->nStates].filterOutput = 1; … … 583 583 retVal = linearize(data); 584 584 rt_accumulate(SIM_TIMER_LINEARIZE); 585 INFO(LOG_STDOUT, "Linear model is created!");585 INFO(LOG_STDOUT, "Linear model is created!"); 586 586 } 587 587 … … 602 602 rt_accumulate(SIM_TIMER_TOTAL); 603 603 const char* plotFormat = omc_flagValue[FLAG_MEASURETIMEPLOTFORMAT]; 604 retVal = printModelInfo(data, modelInfo.c_str(), plotFile.c_str(), plotFormat ? plotFormat : "svg", 604 retVal = printModelInfo(data, modelInfo.c_str(), plotFile.c_str(), plotFormat ? plotFormat : "svg", 605 605 data->simulationInfo.solverMethod, data->simulationInfo.outputFormat, result_file_cstr.c_str()) && retVal; 606 606 } … … 644 644 return 1; 645 645 } 646 sim_result.init(&sim_result, simData);647 INFO2(LOG_SOLVER, "Allocated simulation result data storage for method '%s' and file='%s'", simData->simulationInfo.outputFormat, sim_result.filename);646 sim_result.init(&sim_result, simData); 647 INFO2(LOG_SOLVER, "Allocated simulation result data storage for method '%s' and file='%s'", simData->simulationInfo.outputFormat, sim_result.filename); 648 648 return 0; 649 649 } … … 659 659 * "dopri5" calls an embedded DOPRI5(4)-solver with stepsize control 660 660 */ 661 int callSolver(DATA* simData, string result_file_cstr, string init_initMethod, 661 int callSolver(DATA* simData, string result_file_cstr, string init_initMethod, 662 662 string init_optiMethod, string init_file, double init_time, int lambda_steps, string outputVariablesAtEnd, int cpuTime) 663 663 { … … 730 730 } else if(simData->simulationInfo.solverMethod == std::string("qss")) { 731 731 INFO1(LOG_SOLVER, " | Recognized solver: %s.", simData->simulationInfo.solverMethod); 732 retVal = qss_main(argc, argv, simData->simulationInfo.startTime, 733 simData->simulationInfo.stopTime, simData->simulationInfo.stepSize, 732 retVal = qss_main(argc, argv, simData->simulationInfo.startTime, 733 simData->simulationInfo.stopTime, simData->simulationInfo.stepSize, 734 734 simData->simulationInfo.numSteps, simData->simulationInfo.tolerance, 3); 735 735 #endif … … 740 740 } 741 741 742 sim_result.free(&sim_result, simData);742 sim_result.free(&sim_result, simData); 743 743 744 744 return retVal; … … 818 818 function_initMemoryState(); 819 819 read_input_xml(argc, argv, &(data->modelData), &(data->simulationInfo)); 820 initializeOutputFilter(&(data->modelData), data->simulationInfo.variableFilter);820 initializeOutputFilter(&(data->modelData), data->simulationInfo.variableFilter); 821 821 822 822 /* allocate memory for mixed system solvers */ … … 877 877 printf("<phase>UNKNOWN</phase>\n"); 878 878 printf("<currentStepSize>%g</currentStepSize>\n", data->simulationInfo.stepSize); 879 printf("<oldTime>%.12g</oldTime>\n", data->localData[1]->timeValue);880 printf("<oldTime2>%.12g</oldTime2>\n", data->localData[2]->timeValue);881 printf("<diffOldTime>%g</diffOldTime>\n", data->localData[1]->timeValue-data->localData[2]->timeValue);882 printf("<currentTime>%g</currentTime>\n", data->localData[0]->timeValue);883 printf("<diffCurrentTime>%g</diffCurrentTime>\n", data->localData[0]->timeValue-data->localData[1]->timeValue);879 printf("<oldTime>%.12g</oldTime>\n", data->localData[1]->timeValue); 880 printf("<oldTime2>%.12g</oldTime2>\n", data->localData[2]->timeValue); 881 printf("<diffOldTime>%g</diffOldTime>\n", data->localData[1]->timeValue-data->localData[2]->timeValue); 882 printf("<currentTime>%g</currentTime>\n", data->localData[0]->timeValue); 883 printf("<diffCurrentTime>%g</diffCurrentTime>\n", data->localData[0]->timeValue-data->localData[1]->timeValue); 884 884 */ 885 885 printf("</status>\n"); -
trunk/SimulationRuntime/c/simulation/solver/linearSolverLapack.c
r15342 r15372 60 60 61 61 data->ipiv = (integer*) malloc(size*sizeof(modelica_integer)); 62 ASSERT(data->ipiv, "Could not allocate data efor linear solver lapack.");62 ASSERT(data->ipiv, "Could not allocate data for linear solver lapack."); 63 63 data->nrhs = 1; 64 64 data->info = 0; … … 74 74 { 75 75 DATA_LAPACK* data = (DATA_LAPACK*) *voiddata; 76 76 77 77 free(data->ipiv); 78 78 79 79 return 0; 80 80 } 81 82 81 83 82 /*! \fn solve linear system with lapack method … … 96 95 * We want to look it up among all equations. */ 97 96 int eqSystemNumber = systemData->equationIndex; 98 99 97 int success = 1; 100 98 … … 107 105 systemData->setb(data, systemData); 108 106 109 dgesv_( (integer*) &systemData->size,110 (integer*) &solverData->nrhs,111 systemData->A,112 (integer*) &systemData->size,113 solverData->ipiv,114 systemData->b,115 (integer*) &systemData->size,116 107 dgesv_((integer*) &systemData->size, 108 (integer*) &solverData->nrhs, 109 systemData->A, 110 (integer*) &systemData->size, 111 solverData->ipiv, 112 systemData->b, 113 (integer*) &systemData->size, 114 &solverData->info); 117 115 118 if(solverData->info < 0) { 116 if(solverData->info < 0) 117 { 119 118 WARNING3(LOG_STDOUT, "Error solving linear system of equations (no. %d) at time %f. Argument %d illegal.", (int)systemData->equationIndex, data->localData[0]->timeValue, solverData->info); 120 119 success = 0; 121 }else if(solverData->info > 0) { 122 WARNING4(LOG_STDOUT, 123 "Failed to solve linear system of equations (no. %d) at time %f, system is singular for U[%d,%d].", 120 } 121 else if(solverData->info > 0) 122 { 123 WARNING4(LOG_STDOUT, 124 "Failed to solve linear system of equations (no. %d) at time %f, system is singular for U[%d, %d].", 124 125 (int)systemData->equationIndex, data->localData[0]->timeValue, solverData->info+1, solverData->info+1); 125 126 … … 131 132 char buffer[4096]; 132 133 INDENT(LOG_LS); 133 DEBUG(LOG_LS, "Matrix U:");134 for 134 DEBUG(LOG_LS, "Matrix U:"); 135 for(l = 0; l < systemData->size; l++) 135 136 { 136 137 buffer[0] = 0; 137 for 138 for(k = 0; k < systemData->size; k++) 138 139 sprintf(buffer, "%s%10g ", buffer, systemData->A[l + k*systemData->size]); 139 DEBUG (LOG_LS, buffer);140 DEBUG1(LOG_LS, "%s", buffer); 140 141 } 141 DEBUG(LOG_LS, "Solution x:");142 DEBUG(LOG_LS, "Solution x:"); 142 143 buffer[0] = 0; 143 for 144 for(k = 0; k < systemData->size; k++) 144 145 sprintf(buffer, "%s%10g ", buffer, systemData->b[k]); 145 DEBUG (LOG_LS, buffer);146 DEBUG(LOG_LS, "Solution x:");146 DEBUG1(LOG_LS, "%s", buffer); 147 DEBUG(LOG_LS, "Solution x:"); 147 148 buffer[0] = 0; 148 for 149 for(k = 0; k < systemData->size; k++) 149 150 sprintf(buffer, "%s%10g ", buffer, systemData->b[k]); 150 DEBUG (LOG_LS, buffer);151 DEBUG1(LOG_LS, "%s", buffer); 151 152 RELEASE(LOG_LS); 152 153 } … … 158 159 memcpy(systemData->x, systemData->b, systemData->size*(sizeof(modelica_real))); 159 160 160 161 162 161 return success; 163 162 } -
trunk/SimulationRuntime/c/simulation/solver/linearSolverLapack.h
r15293 r15372 39 39 40 40 #ifdef __cplusplus 41 extern "C" {41 extern "C" { 42 42 #endif 43 43 44 44 #include "blaswrap.h" 45 45 #include "f2c.h" 46 46 47 #ifdef VOID 47 #undef VOID48 #undef VOID 48 49 #endif 49 50 50 extern 51 int dgesv_(integer *n, integer *nrhs, doublereal *a, integer 52 *lda, integer *ipiv, doublereal *b, integer *ldb, integer *info); 51 extern int dgesv_(integer *n, integer *nrhs, doublereal *a, integer *lda, 52 integer *ipiv, doublereal *b, integer *ldb, integer *info); 53 53 54 54 #ifdef __cplusplus 55 }55 } 56 56 #endif 57 58 57 59 58 int allocateLapackData(int size, void **data); -
trunk/SimulationRuntime/c/simulation/solver/stateset.c
r15170 r15372 193 193 for(j=0; j < data->simulationInfo.analyticJacobians[jacIndex].sizeCols; j++) 194 194 sprintf(buffer, "%s%.5e ", buffer, jac[i*data->simulationInfo.analyticJacobians[jacIndex].sizeCols+j]); 195 DEBUG (LOG_DSS, buffer);195 DEBUG1(LOG_DSS, "%s", buffer); 196 196 } 197 197 RELEASE(LOG_DSS); -
trunk/SimulationRuntime/c/util/omc_error.h
r15186 r15372 65 65 extern jmp_buf globalJmpbuf; 66 66 67 /* #define USE_DEBUG_OUTPUT */ 67 #define USE_DEBUG_OUTPUT 68 68 69 69 enum LOG_STREAM
Note: See TracChangeset
for help on using the changeset viewer.