Changeset 13934
- Timestamp:
- 2012-11-17T01:36:22+01:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SimulationRuntime/c/simulation/solver/nonlinearSystem.c
r13758 r13934 117 117 data->simulationInfo.currentNonlinearSystemIndex = sysNumber; 118 118 119 /* enable to avoid division by zero */ 120 data->simulationInfo.noThrowDivZero = 1; 121 119 122 /* strategy for solving nonlinear system 120 123 * … … 127 130 success = solveHybrd(data, sysNumber); 128 131 nonlinsys[sysNumber].solved = success; 132 133 /* enable to avoid division by zero */ 134 data->simulationInfo.noThrowDivZero = 0; 135 129 136 130 137 return 0; -
trunk/SimulationRuntime/c/simulation_data.h
r13787 r13934 335 335 modelica_string variableFilter; 336 336 337 modelica_boolean initial; /* =1 during initialization, 0 otherwise. */ 338 modelica_boolean terminal; /* =1 at the end of the simulation, 0 otherwise. */ 339 modelica_boolean discreteCall; /* =1 for a discrete step, otherwise 0 */ 340 modelica_boolean needToIterate; /* =1 if reinit has been activated, iteration about the system is needed */ 337 /* indicators for simulations state */ 338 modelica_boolean initial; /* =1 during initialization, 0 otherwise. */ 339 modelica_boolean terminal; /* =1 at the end of the simulation, 0 otherwise. */ 340 modelica_boolean discreteCall; /* =1 for a discrete step, otherwise 0 */ 341 modelica_boolean needToIterate; /* =1 if reinit has been activated, iteration about the system is needed */ 341 342 modelica_boolean simulationSuccess; /*=0 the simulation run successful, otherwise an error code is set */ 342 modelica_boolean sampleActivated; /* =1 a sample expresion if going to be actived, 0 otherwise */ 343 modelica_boolean solveContinuous; /* =1 for the first step to initialize all relation, 0 otherwise. */ 343 modelica_boolean sampleActivated; /* =1 a sample expresion if going to be actived, 0 otherwise */ 344 modelica_boolean solveContinuous; /* =1 during the continuous integration to avoid zero-crossings jums, 0 otherwise. */ 345 modelica_boolean noThrowDivZero; /* =1 if solving nonlinear system to avoid THROW for division by zero, 0 otherwise. */ 346 modelica_boolean found_solution; /* helper for mixed systems */ 344 347 345 348 void** extObjs; /* External objects */ … … 385 388 int currentNonlinearSystemIndex; 386 389 387 int found_solution; /* helper for mixed systems */388 389 390 /* delay vars */ 390 391 double tStart; -
trunk/SimulationRuntime/c/util/division.c
r13787 r13934 37 37 #include "omc_error.h" 38 38 39 modelica_real division_error_time(modelica_real b, const char* division_str, modelica_real time, const char* file, long line) 39 modelica_real division_error_time(modelica_real b, const char* division_str, modelica_real time, const char* file, long line, modelica_boolean noThrow) 40 { 41 if (noThrow){ 42 WARNING1(LOG_UTIL, "division by zero in partial equation: %s", division_str); 43 WARNING1(LOG_UTIL, "at Time=%f", time); 44 WARNING(LOG_UTIL, "solver will try to handle that."); 45 } else { 46 WARNING1(LOG_STDOUT, "division by zero in partial equation: %s", division_str); 47 WARNING1(LOG_STDOUT, "at Time=%f", time); 48 WARNING2(LOG_STDOUT, "[line] %ld | [file] %s", line, file); 49 #ifndef __APPLE_CC__ 50 THROW("division by zero"); 51 #endif 52 } 53 return b; 54 } 55 56 modelica_real division_warning_time(modelica_real b, const char* division_str, modelica_real time, const char* file, long line) 40 57 { 41 58 WARNING1(LOG_STDOUT, "division by zero in partial equation: %s", division_str); 42 59 WARNING1(LOG_STDOUT, "at Time=%f", time); 43 WARNING2(LOG_STDOUT, "[line] %ld | [file] %s", line, file); 44 #ifndef __APPLE_CC__ 45 THROW("division by zero"); 46 #endif 60 47 61 return b; 48 62 } 63 64 49 65 50 66 modelica_real division_error(modelica_real b, const char* division_str, const char* file, long line) -
trunk/SimulationRuntime/c/util/division.h
r12006 r13934 40 40 #define DIVISION(a,b,c) (((b) != 0) ? (isnan_error(((a) / (b)), c, __FILE__, __LINE__)) : ((a) / division_error(b, c, __FILE__, __LINE__))) 41 41 #else 42 #define DIVISION(a,b,c) (((b) != 0) ? ((a) / (b)) : ((a) / division_error_time(b, c, time, __FILE__, __LINE__ )))42 #define DIVISION(a,b,c) (((b) != 0) ? ((a) / (b)) : ((a) / division_error_time(b, c, time, __FILE__, __LINE__,data->simulationInfo.noThrowDivZero?1:0))) 43 43 #endif 44 44 #define DIVISIONNOTIME(a,b,c) (((b) != 0) ? ((a) / (b)) : ((a) / division_error(b, c, __FILE__, __LINE__))) 45 45 46 modelica_real division_error_time(modelica_real b, const char* division_str, modelica_real time, const char* file, long line );46 modelica_real division_error_time(modelica_real b, const char* division_str, modelica_real time, const char* file, long line, modelica_boolean noThrow); 47 47 modelica_real division_error(modelica_real b, const char* division_str, const char* file, long line); 48 48 modelica_real isnan_error(modelica_real b, const char* division_str, const char* file, long line); -
trunk/testsuite/simulation/libraries/msl31/Makefile
r13756 r13934 17 17 Modelica.Electrical.Analog.Examples.HeatingRectifier.mos \ 18 18 Modelica.Electrical.Analog.Examples.HeatingResistor.mos \ 19 Modelica.Electrical.Analog.Examples.ShowSaturatingInductor.mos \ 19 20 Modelica.Electrical.Analog.Examples.ShowVariableResistor.mos \ 20 21 Modelica.Electrical.Machines.Examples.DCSE_Start.mos \ … … 102 103 NOTSIMULATETEST= \ 103 104 Modelica.Electrical.Analog.Examples.ControlledSwitchWithArc.mos \ 104 Modelica.Electrical.Analog.Examples.ShowSaturatingInductor.mos \105 105 Modelica.Electrical.Analog.Examples.SwitchWithArc.mos \ 106 106 Modelica.Electrical.Machines.Examples.Rectifier6pulse.mos \ -
trunk/testsuite/simulation/libraries/msl31/Modelica.Electrical.Analog.Examples.ShowSaturatingInductor.mos
r13150 r13934 10 10 loadModel(Modelica,{"3.1"}); 11 11 12 simulate(Modelica.Electrical.Analog.Examples.ShowSaturatingInductor ,stopTime=6.28319978714);12 simulate(Modelica.Electrical.Analog.Examples.ShowSaturatingInductor); 13 13 res := OpenModelica.Scripting.compareSimulationResults("Modelica.Electrical.Analog.Examples.ShowSaturatingInductor_res.mat", 14 14 "ReferenceFiles/Modelica.Electrical.Analog.Examples.ShowSaturatingInductor.mat","Modelica.Electrical.Analog.Examples.ShowSaturatingInductor_diff.csv",0.01,0.00001, … … 27 27 // record SimulationResult 28 28 // resultFile = "Modelica.Electrical.Analog.Examples.ShowSaturatingInductor_res.mat", 29 // simulationOptions = "startTime = 0.0, stopTime = 6.283 19978714, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Modelica.Electrical.Analog.Examples.ShowSaturatingInductor', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = ''",29 // simulationOptions = "startTime = 0.0, stopTime = 6.2832, numberOfIntervals = 628, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Modelica.Electrical.Analog.Examples.ShowSaturatingInductor', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''", 30 30 // messages = "" 31 31 // end SimulationResult; -
trunk/testsuite/simulation/libraries/msl32/Makefile
r13900 r13934 27 27 Modelica.Electrical.Analog.Examples.IdealTriacCircuit.mos \ 28 28 Modelica.Electrical.Analog.Examples.OvervoltageProtection.mos \ 29 Modelica.Electrical.Analog.Examples.ShowSaturatingInductor.mos \ 29 30 Modelica.Electrical.Analog.Examples.ShowVariableResistor.mos \ 30 31 Modelica.Electrical.Analog.Examples.SwitchWithArc.mos \ … … 143 144 Modelica.Electrical.Analog.Examples.AD_DA_conversion.mos \ 144 145 Modelica.Electrical.Analog.Examples.DifferenceAmplifier.mos \ 145 Modelica.Electrical.Analog.Examples.ShowSaturatingInductor.mos \146 146 Modelica.Electrical.Analog.Examples.Rectifier.mos \ 147 147 Modelica.Mechanics.MultiBody.Examples.Elementary.Surfaces.mos \ -
trunk/testsuite/simulation/libraries/msl32/Modelica.Electrical.Analog.Examples.ShowSaturatingInductor.mos
r13603 r13934 10 10 loadModel(Modelica,{"3.2.1"}); 11 11 12 setMatchingAlgorithm("PFPlusExt");13 setIndexReductionMethod("dynamicStateSelection");14 12 simulate(Modelica.Electrical.Analog.Examples.ShowSaturatingInductor); 15 13 getErrorString(); … … 23 21 // Result: 24 22 // true 25 // true26 // true27 23 // record SimulationResult 28 // resultFile = " ",24 // resultFile = "Modelica.Electrical.Analog.Examples.ShowSaturatingInductor_res.mat", 29 25 // simulationOptions = "startTime = 0.0, stopTime = 6.2832, numberOfIntervals = 628, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Modelica.Electrical.Analog.Examples.ShowSaturatingInductor', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''", 30 // messages = "Simulation execution failed for model: Modelica.Electrical.Analog.Examples.ShowSaturatingInductor 31 // warning | division by zero in partial equation: SaturatingInductance1.i / SaturatingInductance1.Ipar because SaturatingInductance1.Ipar == 0: File: C:/OpenModelica1.9.0/lib/omlibrary/Modelica 3.2.1/Electrical/Analog/Basic.mo Line: 439 32 33 // | at Time=0.000000 34 35 // | [line] 144 | [file] Modelica.Electrical.Analog.Examples.ShowSaturatingInductor.c 36 37 // throw | [line] 45 | [file] util/division.c 38 39 // | division by zero 40 41 // " 26 // messages = "" 42 27 // end SimulationResult; 43 28 // "" 44 // " Error Open File!"29 // "Files Equal!" 45 30 // endResult -
trunk/testsuite/simulation/modelica/nonlinear_system/Makefile
r13771 r13934 5 5 NonlinearMixed.mos \ 6 6 Nonlinear.mos \ 7 notanumberTest.mos \ 7 8 8 9
Note: See TracChangeset
for help on using the changeset viewer.