Yes, I have it. It's part of oscillator_functions.h (attached; it should be included by oscillator_functions.cpp).

--
Martin Sjölund

On 2011-01-04 15:24, Christoph Höger wrote:
does your omc create C++ code containing "Modelica_Math_sin_rettype"? If
so, where is it defined?

Am Montag, den 03.01.2011, 19:06 +0100 schrieb Martin Sjölund:
Yes, there are special rules in the flattening that handles certain
external "C" functions in the standard library because they need to be
evaluated quickly (launching gcc to compile and load a dll just to
compute Modelica.Math.sin() is silly).

However, these all work for me (they are just declared external "C", so
nothing special should be needed to make them run):
$ omc a.mos
true
true
record SimulationResult
      resultFile = "oscillator_res.plt",
      simulationOptions = "startTime = 0.0, stopTime = 1.0,
numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl',
fileNamePrefix = 'oscillator', storeInTemp = false, noClean = false,
options = '', outputFormat = 'plt'",
      messages = "",
      timeFrontend = 0.082646233,
      timeBackend = 0.004297787,
      timeSimCode = 0.001765213,
      timeTemplates = 0.003413401,
      timeCompile = 0.811047671,
      timeSimulation = 0.020562325,
      timeTotal = 0.923819948
end SimulationResult;

--
Martin Sjölund

On 2011-01-03 15:51, Christoph Höger wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

addendum: The following model

model mathtest
        parameter Real x = Modelica.Math.sin(1.0);
        Real y;
        equation
        y = Modelica.Math.cos(time) + x;
end mathtest;

gives the following omc output:

class mathtest
    parameter Real x = 0.841470984807897;
    Real y;
equation
    y = Modelica.Math.cos(time) + x;
end mathtest;

So the compiler was able to invoke sin(), even if the runtime system
does not know it?

Am 03.01.2011 15:34, schrieb Christoph Höger:
Thanks for the fast fix. The lookup problem is indeed solved now.

Unfortunately I get a C++ error now:

[choe...@eurybates oscillator]$ LC_ALL=C omc oscillator.mos
true
true
record SimulationResult
      resultFile = "",
      simulationOptions = "startTime = 0.0, stopTime = 10.0,
numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl',
fileNamePrefix = 'oscillator', storeInTemp = false, noClean = false,
options = '', outputFormat = 'plt'",
      messages = "Simulation failed for model: oscillator
Error: Error building simulator. Buildlog: g++ -I. -o oscillator
oscillator.cpp oscillator_functions.cpp    -lsim -linteractive
-I"/opt/openmodelica//include/omc" -march=native -mfpmath=sse
-lsendData -lQtNetwork -lQtCore -lQtGui -lpthread
-L"/opt/openmodelica//lib/omc" -lc_runtime -lf2c oscillator_records.c
oscillator.cpp: In function 'int function_updateDependents()':
oscillator.cpp:918:3: error: 'Modelica_Math_sin_rettype' was not
declared in this scope

Since Modelica.Math.sin is a stdlib function, is there something I need
to do, to get it working?

Am 02.01.2011 16:48, schrieb Martin Sjölund:
This seems to be an issue with evaluation of parameters without
eq-bindings (it should look at start=binding and give a warning). It's
easy to fix it in the model, but thanks for reporting this; I'll look
into the compiler and see if I can make this work quickly.

sinevoltage1(freqHz=50,V=240); // works

--
Martin Sjölund

On 2010-12-29 13:20, Christoph Höger wrote:
Hi all,

the following code

model oscillator
     Modelica.Electrical.Analog.Basic.Capacitor capacitor1;
     Modelica.Electrical.Analog.Sources.SineVoltage sinevoltage1;
     Modelica.Electrical.Analog.Basic.Inductor inductor1;
     Modelica.Electrical.Analog.Basic.Ground ground1;

equation
     connect(inductor1.n,ground1.p);
     connect(capacitor1.p,inductor1.p);
     connect(sinevoltage1.p,capacitor1.p);
     connect(capacitor1.n,sinevoltage1.n);
     connect(capacitor1.n,inductor1.n);
end oscillator;

throws a lookup error (sinevoltage1.freqHz, sineVoltage1.V) with omc
(current trunk) although the flattened output contains the lines:

     parameter Real sinevoltage1.V(quantity = "ElectricPotential", unit =
"V", start = 1.0) "Amplitude of sine wave";
     parameter Real sinevoltage1.phase(quantity = "Angle", unit = "rad",
displayUnit = "deg") = 0.0 "Phase of sine wave";
     parameter Real sinevoltage1.freqHz(quantity = "Frequency", unit =
"Hz", start = 1.0) "Frequency of sine wave";

Any ideas how to circumvent?

best regards,

Christoph



- --
Christoph Höger

Technische Universität Berlin
Fakultät IV - Elektrotechnik und Informatik
Übersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin

Tel.: +49 (30) 314-24890
E-Mail: [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk0h4nkACgkQhMBO4cVSGS9ZhgCfUgaOST9SizEM9p3ZIXVqW837
YXMAn3iuBMrdQ7sYnHgaQ89goAQQ93uQ
=cXHV
-----END PGP SIGNATURE-----


#ifndef oscillator__H
#define oscillator__H
#include "modelica.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#if defined(_MSC_VER)
  #define DLLExport   __declspec( dllexport )
#else
  #define DLLExport /* nothing */
#endif
#include "simulation_runtime.h"
extern "C" {
#define Modelica_Math_sin_rettype_1 targ1
typedef struct Modelica_Math_sin_rettype_s
{
  modelica_real targ1; /* y */
} Modelica_Math_sin_rettype;

Modelica_Math_sin_rettype _Modelica_Math_sin(modelica_real _u);

extern double sin(double _u);
#define Modelica_Math_asin_rettype_1 targ1
typedef struct Modelica_Math_asin_rettype_s
{
  modelica_real targ1; /* y */
} Modelica_Math_asin_rettype;

Modelica_Math_asin_rettype _Modelica_Math_asin(modelica_real _u);

extern double asin(double _u);
}
#endif


Reply via email to