Changeset 96898a5d in OpenModelica
- Timestamp:
- 2016-04-06T18:08:24+02:00 (8 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
- Children:
- 2894deef
- Parents:
- e44d63b8
- git-author:
- Willi Braun <wbraun@…> (04/06/16 18:08:24)
- git-committer:
- hudson <openmodelica@…> (04/06/16 18:08:24)
- Location:
- SimulationRuntime/c
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
SimulationRuntime/c/simulation/solver/dassl.c
rdf3f1c94 r96898a5d 54 54 #endif 55 55 56 static const char *dasslJacobianMethodStr[DASSL_JAC_MAX] = {"unknown",57 "coloredNumerical",58 "coloredSymbolical",59 "internalNumerical",60 "numerical",61 "symbolical"62 };63 64 static const char *dasslJacobianMethodDescStr[DASSL_JAC_MAX] = {"unknown",65 "colored numerical jacobian - default.",66 "colored symbolic jacobian - needs omc compiler flags +generateSymbolicJacobian or +generateSymbolicLinearization.",67 "internal numerical jacobian.",68 "numerical jacobian.",69 "symbolic jacobian - needs omc compiler flags +generateSymbolicJacobian or +generateSymbolicLinearization."70 };71 72 56 /* experimental flag for SKF TLM Master Solver Interface 73 57 * - it's used with -noEquidistantTimeGrid flag. … … 277 261 } 278 262 279 /* if FLAG_ DASSL_JACOBIAN is set, choose dassl jacobian calculation method */280 if (omc_flag[FLAG_ DASSL_JACOBIAN])281 { 282 for(i=1; i< DASSL_JAC_MAX;i++)283 { 284 if(!strcmp((const char*)omc_flagValue[FLAG_ DASSL_JACOBIAN], dasslJacobianMethodStr[i])){263 /* if FLAG_JACOBIAN is set, choose dassl jacobian calculation method */ 264 if (omc_flag[FLAG_JACOBIAN]) 265 { 266 for(i=1; i< JAC_MAX;i++) 267 { 268 if(!strcmp((const char*)omc_flagValue[FLAG_JACOBIAN], JACOBIAN_METHOD[i])){ 285 269 dasslData->dasslJacobian = (int)i; 286 270 break; 287 271 } 288 272 } 289 if(dasslData->dasslJacobian == DASSL_JAC_UNKNOWN)273 if(dasslData->dasslJacobian == JAC_UNKNOWN) 290 274 { 291 275 if (ACTIVE_WARNING_STREAM(LOG_SOLVER)) 292 276 { 293 warningStreamPrint(LOG_SOLVER, 1, "unrecognized jacobian calculation method %s, current options are:", (const char*)omc_flagValue[FLAG_ DASSL_JACOBIAN]);294 for(i=1; i < DASSL_JAC_MAX; ++i)277 warningStreamPrint(LOG_SOLVER, 1, "unrecognized jacobian calculation method %s, current options are:", (const char*)omc_flagValue[FLAG_JACOBIAN]); 278 for(i=1; i < JAC_MAX; ++i) 295 279 { 296 warningStreamPrint(LOG_SOLVER, 0, "%-15s [%s]", dasslJacobianMethodStr[i], dasslJacobianMethodDescStr[i]);280 warningStreamPrint(LOG_SOLVER, 0, "%-15s [%s]", JACOBIAN_METHOD[i], JACOBIAN_METHOD_DESC[i]); 297 281 } 298 282 messageClose(LOG_SOLVER); 299 283 } 300 throwStreamPrint(threadData,"unrecognized jacobian calculation method %s", (const char*)omc_flagValue[FLAG_ DASSL_JACOBIAN]);284 throwStreamPrint(threadData,"unrecognized jacobian calculation method %s", (const char*)omc_flagValue[FLAG_JACOBIAN]); 301 285 } 302 286 /* default case colored numerical jacobian */ … … 304 288 else 305 289 { 306 dasslData->dasslJacobian = DASSL_COLOREDNUMJAC;290 dasslData->dasslJacobian = COLOREDNUMJAC; 307 291 } 308 292 309 293 310 294 /* selects the calculation method of the jacobian */ 311 if(dasslData->dasslJacobian == DASSL_COLOREDNUMJAC ||312 dasslData->dasslJacobian == DASSL_COLOREDSYMJAC ||313 dasslData->dasslJacobian == DASSL_SYMJAC)295 if(dasslData->dasslJacobian == COLOREDNUMJAC || 296 dasslData->dasslJacobian == COLOREDSYMJAC || 297 dasslData->dasslJacobian == SYMJAC) 314 298 { 315 299 if (data->callback->initialAnalyticJacobianA(data, threadData)) 316 300 { 317 301 infoStreamPrint(LOG_STDOUT, 0, "Jacobian or SparsePattern is not generated or failed to initialize! Switch back to normal."); 318 dasslData->dasslJacobian = DASSL_INTERNALNUMJAC;302 dasslData->dasslJacobian = INTERNALNUMJAC; 319 303 } 320 304 } … … 324 308 /* set up the appropriate function pointer */ 325 309 switch (dasslData->dasslJacobian){ 326 case DASSL_COLOREDNUMJAC:310 case COLOREDNUMJAC: 327 311 data->simulationInfo->jacobianEvals = data->simulationInfo->analyticJacobians[data->callback->INDEX_JAC_A].sparsePattern.maxColors; 328 312 dasslData->jacobianFunction = JacobianOwnNumColored; 329 313 break; 330 case DASSL_COLOREDSYMJAC:314 case COLOREDSYMJAC: 331 315 data->simulationInfo->jacobianEvals = data->simulationInfo->analyticJacobians[data->callback->INDEX_JAC_A].sparsePattern.maxColors; 332 316 dasslData->jacobianFunction = JacobianSymbolicColored; 333 317 break; 334 case DASSL_SYMJAC:318 case SYMJAC: 335 319 dasslData->jacobianFunction = JacobianSymbolic; 336 320 break; 337 case DASSL_NUMJAC:321 case NUMJAC: 338 322 dasslData->jacobianFunction = JacobianOwnNum; 339 323 break; 340 case DASSL_INTERNALNUMJAC:324 case INTERNALNUMJAC: 341 325 dasslData->jacobianFunction = dummy_Jacobian; 342 326 /* no user sub-routine for JAC */ … … 344 328 break; 345 329 default: 346 throwStreamPrint(threadData,"unrecognized jacobian calculation method %s", (const char*)omc_flagValue[FLAG_ DASSL_JACOBIAN]);330 throwStreamPrint(threadData,"unrecognized jacobian calculation method %s", (const char*)omc_flagValue[FLAG_JACOBIAN]); 347 331 break; 348 332 } 349 infoStreamPrint(LOG_SOLVER, 0, "jacobian is calculated by %s", dasslJacobianMethodDescStr[dasslData->dasslJacobian]); 350 333 infoStreamPrint(LOG_SOLVER, 0, "jacobian is calculated by %s", JACOBIAN_METHOD_DESC[dasslData->dasslJacobian]); 351 334 352 335 /* if FLAG_DASSL_NO_ROOTFINDING is set, choose dassl with out internal root finding */ -
SimulationRuntime/c/simulation/solver/dassl.h
rdf3f1c94 r96898a5d 38 38 static const unsigned int maxOrder = 5; 39 39 static const unsigned int infoLength = 20; 40 41 enum DASSL_JACOBIAN42 {43 DASSL_JAC_UNKNOWN = 0,44 DASSL_COLOREDNUMJAC,45 DASSL_COLOREDSYMJAC,46 DASSL_INTERNALNUMJAC,47 DASSL_NUMJAC,48 DASSL_SYMJAC,49 DASSL_JAC_MAX50 };51 40 52 41 typedef struct DASSL_DATA{ -
SimulationRuntime/c/util/simulation_options.c
r7d8f15f2 r96898a5d 39 39 /* FLAG_CPU */ "cpu", 40 40 /* FLAG_CSV_OSTEP */ "csvOstep", 41 /* FLAG_DASSL_JACOBIAN */ "dasslJacobian",42 41 /* FLAG_DASSL_NO_RESTART */ "dasslnoRestart", 43 42 /* FLAG_DASSL_NO_ROOTFINDING */ "dasslnoRootFinding", … … 60 59 /* FLAG_IPOPT_MAX_ITER */ "ipopt_max_iter", 61 60 /* FLAG_IPOPT_WARM_START */ "ipopt_warm_start", 61 /* FLAG_JACOBIAN */ "jacobian", 62 62 /* FLAG_L */ "l", 63 63 /* FLAG_L_DATA_RECOVERY */ "l_datarec", … … 105 105 /* FLAG_CPU */ "dumps the cpu-time into the results-file", 106 106 /* FLAG_CSV_OSTEP */ "value specifies csv-files for debuge values for optimizer step", 107 /* FLAG_DASSL_JACOBIAN */ "selects the type of the jacobians that is used for the dassl solver.\n dasslJacobian=[coloredNumerical (default) |numerical|internalNumerical|coloredSymbolical|symbolical].",108 107 /* FLAG_DASSL_NO_RESTART */ "flag deactivates the restart of dassl after an event is performed.", 109 108 /* FLAG_DASSL_NO_ROOTFINDING */ "flag deactivates the internal root finding procedure of dassl.", … … 126 125 /* FLAG_IPOPT_MAX_ITER */ "value specifies the max number of iteration for ipopt", 127 126 /* FLAG_IPOPT_WARM_START */ "value specifies lvl for a warm start in ipopt: 1,2,3,...", 127 /* FLAG_JACOBIAN */ "selects the type of the jacobians that is used for the integrator.\n jacobian=[coloredNumerical (default) |numerical|internalNumerical|coloredSymbolical|symbolical].", 128 128 /* FLAG_L */ "value specifies a time where the linearization of the model should be performed", 129 129 /* FLAG_L_DATA_RECOVERY */ "emit data recovery matrices with model linearization", … … 178 178 /* FLAG_CSV_OSTEP */ 179 179 "value specifies csv-files for debuge values for optimizer step", 180 /* FLAG_DASSL_JACOBIAN */181 " Selects the type of the Jacobian that is used for the dassl solver:\n\n"182 " * coloredNumerical (colored numerical Jacobian, the default).\n"183 " * internalNumerical (internal dassl numerical Jacobian).\n"184 " * coloredSymbolical (colored symbolical Jacobian. Only usable if the simulation is compiled with --generateSymbolicJacobian or --generateSymbolicLinearization.\n"185 " * numerical - numerical Jacobian.\n\n"186 " * symbolical - symbolical Jacobian. Only usable if the simulation is compiled with --generateSymbolicJacobian or --generateSymbolicLinearization.",187 180 /* FLAG_DASSL_NO_RESTART */ 188 181 " Deactivates the restart of dassl after an event is performed.", … … 231 224 /* FLAG_IPOPT_WARM_START */ 232 225 " Value specifies lvl for a warm start in ipopt: 1,2,3,...", 226 /* FLAG_JACOBIAN */ 227 " Selects the type of the Jacobian that is used for the integrator:\n\n" 228 " * coloredNumerical (colored numerical Jacobian, the default).\n" 229 " * internalNumerical (internal dassl numerical Jacobian).\n" 230 " * coloredSymbolical (colored symbolical Jacobian. Only usable if the simulation is compiled with --generateSymbolicJacobian or --generateSymbolicLinearization.\n" 231 " * numerical - numerical Jacobian.\n\n" 232 " * symbolical - symbolical Jacobian. Only usable if the simulation is compiled with --generateSymbolicJacobian or --generateSymbolicLinearization.", 233 233 /* FLAG_L */ 234 234 " Value specifies a time where the linearization of the model should be performed.", … … 339 339 /* FLAG_CPU */ FLAG_TYPE_FLAG, 340 340 /* FLAG_CSV_OSTEP */ FLAG_TYPE_OPTION, 341 /* FLAG_DASSL_JACOBIAN */ FLAG_TYPE_OPTION,342 341 /* FLAG_DASSL_NO_RESTART */ FLAG_TYPE_FLAG, 343 342 /* FLAG_DASSL_NO_ROOTFINDING */ FLAG_TYPE_FLAG, … … 360 359 /* FLAG_IPOPT_MAX_ITER */ FLAG_TYPE_OPTION, 361 360 /* FLAG_IPOPT_WARM_START */ FLAG_TYPE_OPTION, 361 /* FLAG_JACOBIAN */ FLAG_TYPE_OPTION, 362 362 /* FLAG_L */ FLAG_TYPE_OPTION, 363 363 /* FLAG_L_DATA_RECOVERY */ FLAG_TYPE_FLAG, … … 550 550 "NEWTON_MAX" 551 551 }; 552 553 554 const char *JACOBIAN_METHOD[JAC_MAX+1] = { 555 "unknown", 556 557 "coloredNumerical", 558 "coloredSymbolical", 559 "internalNumerical", 560 "numerical", 561 "symbolical", 562 563 "JAC_MAX" 564 }; 565 566 const char *JACOBIAN_METHOD_DESC[JAC_MAX+1] = { 567 "unknown", 568 569 "colored numerical jacobian - default.", 570 "colored symbolic jacobian - needs omc compiler flags +generateSymbolicJacobian or +generateSymbolicLinearization.", 571 "internal numerical jacobian.", 572 "numerical jacobian.", 573 "symbolic jacobian - needs omc compiler flags +generateSymbolicJacobian or +generateSymbolicLinearization.", 574 575 "JAC_MAX" 576 }; 577 -
SimulationRuntime/c/util/simulation_options.h
r7d8f15f2 r96898a5d 47 47 FLAG_CPU, 48 48 FLAG_CSV_OSTEP, 49 FLAG_DASSL_JACOBIAN,50 49 FLAG_DASSL_NO_RESTART, 51 50 FLAG_DASSL_NO_ROOTFINDING, … … 68 67 FLAG_IPOPT_MAX_ITER, 69 68 FLAG_IPOPT_WARM_START, 69 FLAG_JACOBIAN, 70 70 FLAG_L, 71 71 FLAG_L_DATA_RECOVERY, … … 225 225 extern const char *NEWTONSTRATEGY_DESC[NEWTON_MAX+1]; 226 226 227 enum JACOBIAN_METHOD 228 { 229 JAC_UNKNOWN = 0, 230 231 COLOREDNUMJAC, 232 COLOREDSYMJAC, 233 INTERNALNUMJAC, 234 NUMJAC, 235 SYMJAC, 236 237 JAC_MAX 238 }; 239 240 extern const char *JACOBIAN_METHOD[JAC_MAX+1]; 241 extern const char *JACOBIAN_METHOD_DESC[JAC_MAX+1]; 242 243 244 245 227 246 #if defined(__cplusplus) 228 247 }
Note: See TracChangeset
for help on using the changeset viewer.