Changeset 96898a5d in OpenModelica


Ignore:
Timestamp:
2016-04-06T18:08:24+02:00 (8 years ago)
Author:
hudson <openmodelica@…>
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)
Message:

generalize and move dasslJacobian flag

Location:
SimulationRuntime/c
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • SimulationRuntime/c/simulation/solver/dassl.c

    rdf3f1c94 r96898a5d  
    5454#endif
    5555
    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 
    7256/* experimental flag for SKF TLM Master Solver Interface
    7357 *  - it's used with -noEquidistantTimeGrid flag.
     
    277261  }
    278262
    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])){
    285269        dasslData->dasslJacobian = (int)i;
    286270        break;
    287271      }
    288272    }
    289     if(dasslData->dasslJacobian == DASSL_JAC_UNKNOWN)
     273    if(dasslData->dasslJacobian == JAC_UNKNOWN)
    290274    {
    291275      if (ACTIVE_WARNING_STREAM(LOG_SOLVER))
    292276      {
    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)
    295279        {
    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]);
    297281        }
    298282        messageClose(LOG_SOLVER);
    299283      }
    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]);
    301285    }
    302286  /* default case colored numerical jacobian */
     
    304288  else
    305289  {
    306     dasslData->dasslJacobian = DASSL_COLOREDNUMJAC;
     290    dasslData->dasslJacobian = COLOREDNUMJAC;
    307291  }
    308292
    309293
    310294  /* 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)
    314298  {
    315299    if (data->callback->initialAnalyticJacobianA(data, threadData))
    316300    {
    317301      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;
    319303    }
    320304  }
     
    324308  /* set up the appropriate function pointer */
    325309  switch (dasslData->dasslJacobian){
    326     case DASSL_COLOREDNUMJAC:
     310    case COLOREDNUMJAC:
    327311      data->simulationInfo->jacobianEvals = data->simulationInfo->analyticJacobians[data->callback->INDEX_JAC_A].sparsePattern.maxColors;
    328312      dasslData->jacobianFunction =  JacobianOwnNumColored;
    329313      break;
    330     case DASSL_COLOREDSYMJAC:
     314    case COLOREDSYMJAC:
    331315      data->simulationInfo->jacobianEvals = data->simulationInfo->analyticJacobians[data->callback->INDEX_JAC_A].sparsePattern.maxColors;
    332316      dasslData->jacobianFunction =  JacobianSymbolicColored;
    333317      break;
    334     case DASSL_SYMJAC:
     318    case SYMJAC:
    335319      dasslData->jacobianFunction =  JacobianSymbolic;
    336320      break;
    337     case DASSL_NUMJAC:
     321    case NUMJAC:
    338322      dasslData->jacobianFunction =  JacobianOwnNum;
    339323      break;
    340     case DASSL_INTERNALNUMJAC:
     324    case INTERNALNUMJAC:
    341325      dasslData->jacobianFunction =  dummy_Jacobian;
    342326      /* no user sub-routine for JAC */
     
    344328      break;
    345329    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]);
    347331      break;
    348332  }
    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]);
    351334
    352335  /* if FLAG_DASSL_NO_ROOTFINDING is set, choose dassl with out internal root finding */
  • SimulationRuntime/c/simulation/solver/dassl.h

    rdf3f1c94 r96898a5d  
    3838static const unsigned int maxOrder = 5;
    3939static const unsigned int infoLength = 20;
    40 
    41 enum DASSL_JACOBIAN
    42 {
    43   DASSL_JAC_UNKNOWN = 0,
    44   DASSL_COLOREDNUMJAC,
    45   DASSL_COLOREDSYMJAC,
    46   DASSL_INTERNALNUMJAC,
    47   DASSL_NUMJAC,
    48   DASSL_SYMJAC,
    49   DASSL_JAC_MAX
    50 };
    5140
    5241typedef struct DASSL_DATA{
  • SimulationRuntime/c/util/simulation_options.c

    r7d8f15f2 r96898a5d  
    3939  /* FLAG_CPU */                   "cpu",
    4040  /* FLAG_CSV_OSTEP */             "csvOstep",
    41   /* FLAG_DASSL_JACOBIAN */        "dasslJacobian",
    4241  /* FLAG_DASSL_NO_RESTART */      "dasslnoRestart",
    4342  /* FLAG_DASSL_NO_ROOTFINDING */  "dasslnoRootFinding",
     
    6059  /* FLAG_IPOPT_MAX_ITER */        "ipopt_max_iter",
    6160  /* FLAG_IPOPT_WARM_START */      "ipopt_warm_start",
     61  /* FLAG_JACOBIAN */              "jacobian",
    6262  /* FLAG_L */                     "l",
    6363  /* FLAG_L_DATA_RECOVERY */       "l_datarec",
     
    105105  /* FLAG_CPU */                   "dumps the cpu-time into the results-file",
    106106  /* 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].",
    108107  /* FLAG_DASSL_NO_RESTART */      "flag deactivates the restart of dassl after an event is performed.",
    109108  /* FLAG_DASSL_NO_ROOTFINDING */  "flag deactivates the internal root finding procedure of dassl.",
     
    126125  /* FLAG_IPOPT_MAX_ITER */        "value specifies the max number of iteration for ipopt",
    127126  /* 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].",
    128128  /* FLAG_L */                     "value specifies a time where the linearization of the model should be performed",
    129129  /* FLAG_L_DATA_RECOVERY */       "emit data recovery matrices with model linearization",
     
    178178  /* FLAG_CSV_OSTEP */
    179179  "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.",
    187180  /* FLAG_DASSL_NO_RESTART */
    188181  "  Deactivates the restart of dassl after an event is performed.",
     
    231224  /* FLAG_IPOPT_WARM_START */
    232225  "  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.",
    233233  /* FLAG_L */
    234234  "  Value specifies a time where the linearization of the model should be performed.",
     
    339339  /* FLAG_CPU */                   FLAG_TYPE_FLAG,
    340340  /* FLAG_CSV_OSTEP */             FLAG_TYPE_OPTION,
    341   /* FLAG_DASSL_JACOBIAN */        FLAG_TYPE_OPTION,
    342341  /* FLAG_DASSL_NO_RESTART */      FLAG_TYPE_FLAG,
    343342  /* FLAG_DASSL_NO_ROOTFINDING */  FLAG_TYPE_FLAG,
     
    360359  /* FLAG_IPOPT_MAX_ITER */        FLAG_TYPE_OPTION,
    361360  /* FLAG_IPOPT_WARM_START */      FLAG_TYPE_OPTION,
     361  /* FLAG_JACOBIAN */              FLAG_TYPE_OPTION,
    362362  /* FLAG_L */                     FLAG_TYPE_OPTION,
    363363  /* FLAG_L_DATA_RECOVERY */       FLAG_TYPE_FLAG,
     
    550550  "NEWTON_MAX"
    551551};
     552
     553
     554const 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
     566const 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  
    4747  FLAG_CPU,
    4848  FLAG_CSV_OSTEP,
    49   FLAG_DASSL_JACOBIAN,
    5049  FLAG_DASSL_NO_RESTART,
    5150  FLAG_DASSL_NO_ROOTFINDING,
     
    6867  FLAG_IPOPT_MAX_ITER,
    6968  FLAG_IPOPT_WARM_START,
     69  FLAG_JACOBIAN,
    7070  FLAG_L,
    7171  FLAG_L_DATA_RECOVERY,
     
    225225extern const char *NEWTONSTRATEGY_DESC[NEWTON_MAX+1];
    226226
     227enum JACOBIAN_METHOD
     228{
     229  JAC_UNKNOWN = 0,
     230
     231  COLOREDNUMJAC,
     232  COLOREDSYMJAC,
     233  INTERNALNUMJAC,
     234  NUMJAC,
     235  SYMJAC,
     236
     237  JAC_MAX
     238};
     239
     240extern const char *JACOBIAN_METHOD[JAC_MAX+1];
     241extern const char *JACOBIAN_METHOD_DESC[JAC_MAX+1];
     242
     243
     244
     245
    227246#if defined(__cplusplus)
    228247  }
Note: See TracChangeset for help on using the changeset viewer.