christiankral / PhotoVoltaics

Modelica library for the simulation of photo voltaic cells and modules
Other
25 stars 17 forks source link

Initialization of Testing models #3

Closed tbeu closed 7 years ago

tbeu commented 7 years ago

All of the testing models do not succeed to initialize in SimulationX. E.g., PhotoVoltaics.Testing.SimpleCellResistor. Depending on the solver it raises a Floating Point overflow exception, or simply stops to iterate.

tbeu commented 7 years ago

From debugging the FP overflow

//_cell_m = 1.4892411615919498e+031;
_cell_diode_m=_cell_m;
_cell_diode_Ids=8.5399999999999991/(-1+exp(24.488272557445249/_cell_diode_m));
christiankral commented 7 years ago

cell.m is a parameter which is iterated in an initial equation of the class PhotoVoltaics.Components.Cells.Simple. The start value 1 is indicated: final parameter Real m(start = 1, fixed = false) "Ideality factor of diode";

So I am not sure what the exact issue is in this case.

However, I updated the Testing examples in 6c81421, since the were still some initialization issues, most likely caused by the previously used record constructor of the examples. Package Testing should be OK by now. I was testing the all five examples with OpenModelica and they are running fine.

tbeu commented 7 years ago

Looks like a tool issue which fails to solve the minimal model

model Simple
  final parameter Real m(start = 1, fixed = false);
  final parameter Real IsdRef(start = 1E-6, fixed = false);
  final parameter Real IphRef = 8.54;
  parameter Integer ns = 48;
  parameter Real VocRef = 30.2;
  final parameter Real VocCellRef = VocRef / ns;
  parameter Real VmpRef = 24.0;
  final parameter Real VmpCellRef = VmpRef / ns;
  parameter Real ImpRef = 7.71;
  constant Real Q = 1.6021766208E-19;
  parameter Real TRef = 298.15;
  final parameter Real VtCellRef = 1.38064852e-23 * TRef / Q;
initial equation 
  IphRef = IsdRef * (exp(VocCellRef / m / VtCellRef) - 1);
  IphRef = IsdRef * (exp(VmpCellRef / m / VtCellRef) - 1) + ImpRef;
end Simple;
tbeu commented 7 years ago

We analyzed the problem. The reason that SimulationX fails is due to the damping strategy of the non-linear solver. If the number of iterations is increased, the solver converges to the expected solution.

The solver also converges with the standard solver settings, if the start values are set to be closer at the solution, i.e., m(start = 2) and IsdRef(start = 1E-4). You might consider to use this improved start values. Thanks.

christiankral commented 7 years ago

I was running into convergence problems in OpenModelica with the nonlinear solver, as well. You may be interested in https://trac.openmodelica.org/OpenModelica/ticket/4222. However, I will perform tests with your proposed start values.

christiankral commented 7 years ago

I incorporated you initial conditions into master and version v0.3.1. With the actual nightly built of OpenModelica the problems described in https://trac.openmodelica.org/OpenModelica/ticket/4222 also disappeared. So thanks a lot for your support.

christiankral commented 7 years ago

Do you think we can close this ticket, as your initial conditions are applied to the library?

tbeu commented 7 years ago

We used this Simple.mo (with original initial value settings) example as test case to improve damping strategies of different solvers. So it was a very relevant test case.