#2769 closed defect (fixed)
Partially evaluated function is not included in c-code
Reported by: | anonymous | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.1 |
Component: | Backend | Version: | trunk |
Keywords: | Cc: |
Description
The following code works perfectly, but when the line at the end starting with "real b = ..." is removed the function equilibriumPressureAdsorption() is not included in the c-code anymore and simulation crashes with the following error message. I am running the nightly build from Aug. 3rd 2014.
Error message:
MetalHydrideStorage.M_functions.o:MetalHydrideStorage.M_functions.c:(.text+0xfa7): undefined reference to `omc_MetalHydrideStorage_M_equilibriumPressureAdsorption' collect2: ld returned 1 exit status mingw32-make: *** [omc_main_target] Error 1 Compilation process exited with code 2
Code:
model M import SI = Modelica.SIunits; record State SI.Temperature T; SI.AbsolutePressure p; Real omega; end State; function equilibriumPressureAdsorption input State s; output SI.Pressure p_eq; protected Real p1, p2; constant Real alpha = 0.5; constant Real a1 = -4.884, a2 = -2374.7, a3 = 3.4129 * 10 ^ (-3), a4 = 48.816, a5 = -50.404, a6 = 22.711, a7 = -7.9717, a8 = 1.233; constant Real b1 = -452.34, b2 = 15.522, b3 = 4.0954, b4 = -1.3222 * 10 ^ (-2), b5 = 1.4406 * 10 ^ (-5); Real omega = s.omega * 100; algorithm p1 := exp(a1 + a2 / s.T + a3 * s.T + a4 * omega ^ alpha + a5 * omega + a6 * omega ^ 2 + a7 * omega ^ 3 + a8 * omega ^ 4); p2 := exp(b1 + b2 * omega + b3 * s.T + b4 * s.T ^ 2 + b5 * s.T ^ 3); p_eq := p1 + p2; end equilibriumPressureAdsorption; function equilibriumLoadingAdsorption "Uses modelica's root finding algorithm to calculate the equilibrium loading based on the equilibrium pressure function" input State s; output Real omega_eq; algorithm omega_eq := Modelica.Math.Nonlinear.solveOneNonlinearEquation(function equilibriumLoadingAdsorptionDummy(s = s), 0, 0.02, 1e-006); end equilibriumLoadingAdsorption; function equilibriumLoadingAdsorptionDummy extends Modelica.Math.Nonlinear.Interfaces.partialScalarFunction; input State s; algorithm y := equilibriumPressureAdsorption(State(T = s.T, p = s.p, omega = u)) - s.p; end equilibriumLoadingAdsorptionDummy; Real r = equilibriumLoadingAdsorption(State(time * 100 + 273.15, 50, 0.01)); Real b = equilibriumPressureAdsorption(State(time * 100 + 273.15, 50, 0.01)); annotation(uses(Modelica(version = "3.2.1"))); end M;
Change History (3)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
comment:2 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
comment:3 by , 10 years ago
Component: | Unknown → Backend |
---|
Note:
See TracTickets
for help on using tickets.
Should be fixed in r21741.