[TRNSYS-users] numerical solution in new type with C++

marcello.caciolo at cofelyaxima-gdfsuez.com marcello.caciolo at cofelyaxima-gdfsuez.com
Mon Oct 6 01:59:41 PDT 2014


Dear Iris,

I don't know if you resolved this issue. 

I checked in the source code and subroutines SetNumericalDerivative and Tau_Alpha (with an underscore) are not defined in the module TRNSYSFUNCTIONS (as SetNumberofOutputs). Thus, I suppose that these subroutines, as SetNumberofOutputs, should not be declared in the header file.

If it doesn't work, you could try to declare these two subroutines as external, without the TRNSYSFUNCTIONS_mp_ : 

extern "C" __declspec(dllimport) void	_cdecl SETNUMERICALDERIVATIVE(int, double); 
extern "C" __declspec(dllimport) void	_cdecl TAU_ALPHA(int, double); 

#define SetNumericalDerivative SETNUMERICALDERIVATIVE
#define Tau_alpha TAU_ALPHA

Again, I am not expert in C++ and I do not assure that this works! 

Hope this helps.

Best regards,

Marcello CACIOLO
Responsable Outils et Méthodes d'Analyse Energétique

Cellule Efficacité Energétique et Environnementale - Pôle Projets et 
Réalisations
46 Boulevard de la Prairie au Duc
BP 40119 - 44201 Nantes Cedex 02
Tél.: +33 02 40 41 06 57
marcello.caciolo at cofelyaxima-gdfsuez.com
P Pensez à l'environnement avant d'imprimer ce message

-----Message d'origine-----
De : TRNSYS-users [mailto:trnsys-users-bounces at lists.onebuilding.org] De la part de iris.reichenbach at iwtt.tu-freiberg.de
Envoyé : mardi 23 septembre 2014 16:08
À : trnsys-users at lists.onebuilding.org
Objet : Re: [TRNSYS-users] numerical solution in new type with C++

Dear all,
Thanks again to Marcello and David, your suggestions helped. I'm stuck now at another, related problem. I inserted the following lines into the header file:

extern "C" __declspec(dllimport) void	_cdecl  
TRNSYSFUNCTIONS_mp_SETNUMERICALDERIVATIVE(int, double); extern "C" __declspec(dllimport) double _cdecl TRNSYSFUNCTIONS_mp_GETNUMERICALSOLUTION(int);
extern "C" __declspec(dllimport) double _cdecl TRNSYSFUNCTIONS_mp_TAUALPHA(int,double,double,double,double,double);

Now I get the following error message when I try to compile:
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__TRNSYSFUNCTIONS_mp_SETNUMERICALDERIVATIVE" in Funktion "_TYPE236".
1>Type236.obj : error LNK2019: Verweis auf nicht aufgelöstes externes
Symbol "__imp__TRNSYSFUNCTIONS_mp_TAUALPHA" in Funktion "_TYPE236".


(This translates to something like unresolved external symbol) Note that I addded lines for SetNumericalDerivative, GetNumericalDerivative and TauAlpha, but get the error only for two of these lines, even though I'm using all three functions. Are these possibly not referenced in the dll or is there an error in my changes to the h file? Any help is appreciated.
Thanks,
Iris


Zitat von marcello.caciolo at cofelyaxima-gdfsuez.com:

> Dear Iris,
>
> I am not an expert of C++ programming, but I think that, in order to 
> be consistent with Fortran declaration of these functions, you should 
> just declare the functions in the .h header file as :
>
> extern "C" __declspec(dllimport) void _cdecl 
> TRNSYSFUNCTIONS_mp_SETNUMERICALDERIVATIVE(int, double); extern "C" 
> __declspec(dllimport) double _cdecl 
> TRNSYSFUNCTIONS_mp_GETNUMERICALSOLUTION(int);
>
> and after
>
> #define SetNumericalDerivative 
> TRNSYSFUNCTIONS_mp_SETNUMERICALDERIVATIVE
> #define GetNumericalSolution TRNSYSFUNCTIONS_mp_GETNUMERICALSOLUTION
>
>
> Hope this helps!
>
> Marcello Caciolo
> Responsable Outils et Méthodes d'Analyse Energétique
>
>
> Cellule Efficacité Energétique et Environnementale - Pôle Projets et 
> Réalisations
> 46 Boulevard de la Prairie au Duc
> BP 40119 - 44201 Nantes Cedex 02
> Tél.: +33 02 40 41 06 57
> marcello.caciolo at cofelyaxima-gdfsuez.com
> P Pensez à l'environnement avant d'imprimer ce message
>
>
>
> -----Message d'origine-----
> De : TRNSYS-users
> [mailto:trnsys-users-bounces at lists.onebuilding.org] De la part de Iris 
> Reichenbach Envoyé : jeudi 28 août 2014 13:04 À : TRNSYS users mailing 
> list at OneBuilding.org Objet : Re: [TRNSYS-users] numerical solution 
> in new type with C++
>
> Dear David,
>
> Thank you for your response, I tried to do this. However, I have no 
> idea what I am doing here.
> As a first try I just added the lines
> extern "C" __declspec(dllimport) double _cdecl 
> TRNSYSFUNCTIONS_mp_SETNUMERICALDERIVATIVE(void);
> extern "C" __declspec(dllimport) double _cdecl 
> TRNSYSFUNCTIONS_mp_GETNUMERICALSOLUTION(void);
> and
> #define SetNumericalDerivative 
> TRNSYSFUNCTIONS_mp_SETNUMERICALDERIVATIVE
> #define GetNumericalSolution TRNSYSFUNCTIONS_mp_GETNUMERICALSOLUTION
> to the TRNSYS.h file. However, this did not work. I also noticed that 
> there is a getNumericalSolver in the .h file, I'd think that implies 
> that there should be a numerical solver accessible for C++?
> Also, I have the same problem for the function Tau_Alpha, I also can't 
> use it.
> Could someone give me any more hints on how to either change the .h 
> file or use another way of finding the numerical solutions?
> Thanks in advance,
> Iris
>
>
>
> Am 27.08.2014 17:46, schrieb David BRADLEY:
>> Iris,
>>  I am no expert in writing C++ components (in fact I have never tried 
>> it). My guess, however, is that you will need to modify the TRNSYS.h 
>> file to make sure that the setNumericalDerivative() and
>> getNumericalSolution() functions are actually defined in there.
>> Kind regards,
>>  David
>>
>>
>> On 8/27/2014 07:52, Iris Reichenbach wrote:
>>> Dear fellow TRNSYS users,
>>> I have the following problem. I'm trying to write a new type for 
>>> TRNSYS in C++, which involves the numerical solution of differential 
>>> equations. Usually, SetNumericalDerivative is used to set the 
>>> numerical derivatives and then GetNumericalSolution is used to 
>>> obtain the solution of the differential equation. However, when 
>>> trying to compile my code the compiler gives the following error: 
>>> "error
>>> C3861:  "getNumericalSolution": Bezeichner wurde nicht gefunden."
>>> That is, it can't find the identifier getNumericalSolution.
>>> I also tried to instead use the older form and write dtdt[i] = x, 
>>> instead of SetNumericalDerivative(i,x), but here I got the error 
>>> message "error C2109: Index erfordert ein Array oder einen Zeigertyp"
>>> (that is index requires an array or a pointer).
>>> I  use the project CPP-Mvs2003, which is included in 
>>> TRNSYS/Compilers, so it has access to TRNSYS.h and TRNDll.lib, and I 
>>> also successfully used my setup to generate another custom type, 
>>> albeit without any numerical solution.
>>> So my question is: how can I solve numerical equations with a type 
>>> written in C++? How do I set the derivatives and how do I access the 
>>> solutions? Do GetNumericalSolution/SetNumericalDerivative not work 
>>> with C++ (I didn't find them in TRNSYS.h) and if so, what do I use 
>>> instead?
>>> Thanks in advance for any pointers!
>>> Cheers,
>>> Iris
>>> _______________________________________________
>>> TRNSYS-users mailing list
>>> TRNSYS-users at lists.onebuilding.org
>>> http://lists.onebuilding.org/listinfo.cgi/trnsys-users-onebuilding.o
>>> r
>>> g



_______________________________________________
TRNSYS-users mailing list
TRNSYS-users at lists.onebuilding.org
http://lists.onebuilding.org/listinfo.cgi/trnsys-users-onebuilding.org


More information about the TRNSYS-users mailing list