Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the non-linearity of the new Media #40

Closed
damienpicard opened this issue Mar 5, 2014 · 8 comments
Closed

Problem with the non-linearity of the new Media #40

damienpicard opened this issue Mar 5, 2014 · 8 comments

Comments

@damienpicard
Copy link
Contributor

I re-run the test where a simple hydraulic system (a pump, a boiler with on-off control, a heated pipe and so varying input) to compare IDEAS and IDEAS using annex 60 baseClasses (see issue #15 ).

After approximately 2*E+5 seconds, I get the error that Dymola cannot solve this non-linear problem. I don't have the problem if I run the previous Media implementation (ConstantPropertyLiquidWater, for example from commit SHA: SHAc7a3e2d106d4f85b451ee9d414ca842827078501)

To illustrate the problem, I add in Annex60/IDEAS_a60 two save total, one with the current Media implementation (giving the problem), one with the previous implementation (running smoothly). This can be found at: https://github.com/damienpicard/modelica-annex60/tree/issue40_HydraulicTestBenchIDEAS

@mwetter
Copy link
Contributor

mwetter commented Mar 5, 2014

@mwetter
Copy link
Contributor

mwetter commented Mar 26, 2014

I tested the model on the above branch on Linux. The translation failed because Dymola 2014 FD01 can for some reason not translate a CombiTable2D that was exported in a total model. The error message is

/usr/bin/ld: cannot find -lModelicaStandardTables
collect2: ld returned 1 exit status

@damienpicard : can you please upload a model that is not a total model.

@mwetter
Copy link
Contributor

mwetter commented Mar 31, 2014

The model can be translated after running

sudo ln -s /opt/dymola/Modelica/Library/Modelica\ 3.2.1/Resources/Library/linux32/libModelicaStandardTables.a /opt/dymola/bin/lib/libModelicaStandardTables.a

@mwetter
Copy link
Contributor

mwetter commented Mar 31, 2014

The old media had the following statistics

Number of mixed real/discrete systems of equations: 0
Sizes of linear systems of equations: {4}
Sizes after manipulation of the linear systems: {0}
Sizes of nonlinear systems of equations: {1}
Sizes after manipulation of the nonlinear systems: {1}
Number of numerical Jacobians: 0

The new medium has

Assumed default initial conditions: 3
Number of mixed real/discrete systems of equations: 0
Sizes of linear systems of equations: {3}
Sizes after manipulation of the linear systems: {0}
Sizes of nonlinear systems of equations: {7, 38}
Sizes after manipulation of the nonlinear systems: {4, 2}
Number of numerical Jacobians: 1

Initialization problem
Sizes of nonlinear systems of equations: {38}
Sizes after manipulation of the nonlinear systems: {2}
Number of numerical Jacobians: 1

Next, I replaced in the new medium model the density (in BaseProperties) to use a constant value rather than d=density(state). This leads to the following statistics

Number of mixed real/discrete systems of equations: 0
Sizes of linear systems of equations: {4}
Sizes after manipulation of the linear systems: {0}
Sizes of nonlinear systems of equations: {1}
Sizes after manipulation of the nonlinear systems: {1}
Number of numerical Jacobians: 0

and the model simulates.

In summary, the model has the following issues:

  1. Using a density that depends on temperature leads to a larger system of equations.
  2. The function Modelica.Math.Vectors.interpolate that is used in IDEAS boiler model is not differentiable (at least it does not declare that it is smooth). This function is called by Dymola in a way that requires its derivative, which is then approximated numerically. This leads to the numerical Jacobian, which may contribute to the model not to converge.

I suggest

  1. to replace Modelica.Math.Vectors.interpolate with a function that is differentiable such as Annex60.Utilities.Math.Functions.cubicHermiteLinearExtrapolation.
  2. to add in the medium a constant that allows use of a constant density.

@damienpicard
Copy link
Contributor Author

Thanks Micheal for this feedback.

Replacing Modelica.Math.Vectors.interpolate by Modelica.Blocks.Tables.CombiTable2D with smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative already solved the problem.

By replacing the density and its derivatives by a constant, the CPU-time decreases with a factor 4.7.

I would indeed be in favor of a parameter allowing constant density for water or a simplified medium such as Modelica.Media.Water.ConstantPropertyLiquidWater.

@mwetter
Copy link
Contributor

mwetter commented May 28, 2014

@mwetter
Copy link
Contributor

mwetter commented Aug 30, 2014

Closed ticket as I merged #89

@mwetter mwetter closed this as completed Aug 30, 2014
@thorade
Copy link
Member

thorade commented Mar 13, 2015

Ran into the same problem with Total Models on Windows, the fix is more or less identical.
On Linux, the command for creating symlinks is ln -s realfile symlink,
on Windows the command is mklink symlink realfile.

For some reason I had to create a symlink for the .lib file, not for the .a file.
The full command then reads:
mklink "C:\Program Files (x86)\Dymola 2015 FD01\bin\lib\ModelicaStandardTables.lib" "C:\Program Files (x86)\Dymola 2015 FD01\Modelica\Library\Modelica 3.2.1\Resources\Library\win32\ModelicaStandardTables.lib"

Also note I had to use win32 even though I am using Dymola 64bit on a Windows 7 64bit.
Might be different for different setups (e.g. when using the flag Advanced.CompileWith64 !?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants