[TRNSYS-users] Fw: error message in calling matlab from trnsys

Mehdi Shahrestani mahdishahrestani at yahoo.com
Wed Feb 23 05:38:12 PST 2011


Hi 

 

I have finally solved it. As I have already said it should be of your Matlab
script.

 

I extract you matlab code from the Trnsys structure to find whether it works
apart from Trnsys. It was written in a very imprecise way. 

 

Following are the major errors.

1-     Xa and Xb come to complex numbers which are not meaningful for
transys. Also it could not be meaningful for adsorption system as well. Be
careful when you are doing numerical simulation of a phenomena or process. I
suggest you to back to the references of the process which these two
equations represent. As I do not know the process I simply assume real
number for these two parameters.

 

Xa = Xo*exp(-k1*(((T+delT)/Tsc)-1)^n);

Xb =Xo*exp(-k1*((T/Tsc)-1)^n);

            

2-     Parameters Tev=283 Ta2=300 Ti=300 was not defined whereas they have
called in the simulation a lot. For solving the problem I did assumption for
these parapets. 

 

      Tev=283;

      Ta2=300;

      Ti=300;

 

3-     In your script following red multiplication sign was missed. 

 

       Xmax = Xo*exp(-k1*((Ta2/Tse)-1)^n);

       Xmin = Xo*exp(-k1*((Tgen/Tsc)-1)^n);

 

 

4-     You was not careful about using caps lock for naming variables.
Following lines are corrected.

 

          Wrong:

 

Tg1 = Tsc*(((-1/k1)*log(xmax/xo))^(1/n)+1);

Ta1 = Tse*(((-1/k1)*log(xmin/xo))^(1/n)+1);

Tg2 = Tsc*(((-1/k1)*log(xmin/xo))^(1/n)+1);

Ta2 = Tse*(((-1/k1)*log(xmax/xo))^(1/n)+1);

            Qe = mac*(xmax-xmin)*(Lev - cpml*(Tcond - Tev));

 

 

      After correction

Tg1 = Tsc*(((-1/k1)*log(Xmax/Xo))^(1/n)+1);

Ta1 = Tse*(((-1/k1)*log(Xmin/Xo))^(1/n)+1);

Tg2 = Tsc*(((-1/k1)*log(Xmin/Xo))^(1/n)+1);

Ta2 = Tse*(((-1/k1)*log(Xmax/Xo))^(1/n)+1);

            Qe = mac*(xmax-xmin)*(Lev - cpml*(Tcond - Tev));

 

 

 

Also, I have some very important comment for you. 

 

1-     When you want to write matlab script with Trnsys. First run you
script in Matlab to diagnose it. Otherwise it would be some how impossible
to find your matlab errors in Trnsys.

2-     You are not forced to use mixed variable names (big and small
characters) variables are not the password which should be difficult to
hack.

3-     Before sending an email to group make sure that you have do all the
basic check. It is not supposed that somebody check you matlab script to
find basic programming error. 

4-     Check the type 155 solely first and then put it in the complex model.


 

 

 

Finally, you have to rectify my assumption (Items 1,2 ) regarding to the
process of adsorption system. 

As attached please fined the modified Mfile and tpf file.

 

Hope it helps

Mehdi

 

 

 

 

 

 

  _____  

From: Rekiya Suleiman [mailto:omohu_s at yahoo.com] 
Sent: 23 February 2011 10:39
To: Mehdi Shahrestani
Subject: Fw: [TRNSYS-users] Fw: error message in calling matlab from trnsys

 

Dear Mehdi

 

Good day to you. Please have you made any progress with my files.

Regards

 

Rekiyat

 

----- Forwarded Message ----
From: Rekiya Suleiman <omohu_s at yahoo.com>
To: Mehdi Shahrestani <mahdishahrestani at yahoo.com>
Sent: Tue, February 22, 2011 9:43:28 PM
Subject: Re: [TRNSYS-users] Fw: error message in calling matlab from trnsys

Dear Mehdi

 

Sorry for the mix up, I thought the m file was attached. Please I have
attached it now.

 

Rekiyat

 

  _____  

From: Mehdi Shahrestani <mahdishahrestani at yahoo.com>
To: Rekiya Suleiman <omohu_s at yahoo.com>
Sent: Tue, February 22, 2011 8:53:28 PM
Subject: RE: [TRNSYS-users] Fw: error message in calling matlab from trnsys

Dear Rekiyat 

 

I just sent me tmf file. Also the m file "AdsorptionUnit.m" is needed. 

 

 

  _____  

From: Rekiya Suleiman [mailto:omohu_s at yahoo.com] 
Sent: 22 February 2011 13:32
To: Mehdi Shahrestani
Subject: Re: [TRNSYS-users] Fw: error message in calling matlab from trnsys

 

Dear Mehdi


Please find attached the code I have written for an adsorption bed immersed
in a water tank also shown in the simulation studio attached file. Hope you
would be able to help.

Thank you.

 

Rekiyat

 

 

  _____  

From: Mehdi Shahrestani <mahdishahrestani at yahoo.com>
To: Rekiya Suleiman <omohu_s at yahoo.com>
Sent: Tue, February 22, 2011 12:50:36 PM
Subject: RE: [TRNSYS-users] Fw: error message in calling matlab from trnsys

Dear Rekiyat 

 

If the example Calling Matlab-MultipleUnits.tpf is already runs, it means
that there is no problem for your type 155 dll.

 

I think the problem could be related to your model.

I myself always check my simulation, step by step. That is because in this
way you can easily detect the error. Otherwise at the end of your modelling
you would be facing a complex model which is not simple to be diagnosed.

 

If you want send me your file to check.

 

Mehdi

 

 

  _____  

From: Rekiya Suleiman [mailto:omohu_s at yahoo.com] 
Sent: 22 February 2011 11:30
To: Mehdi Shahrestani
Cc: trnsys-users at cae.wisc.edu
Subject: Re: [TRNSYS-users] Fw: error message in calling matlab from trnsys

 

Dear Mehdi

Thanks for your prompt response. The 'Type 155.dll' I have actually works
with the examples Calling Matlab in TRNSYS but when I try to call my own
code written also in matlab it gives the error 'undefined command/function
'trnInputs''. I have tried your suggestions without success, is there
anything else I can try.

Regards

 

Rekiyat

 

  _____  

From: Mehdi Shahrestani <mahdishahrestani at yahoo.com>
To: Rekiya Suleiman <omohu_s at yahoo.com>
Sent: Tue, February 22, 2011 11:48:42 AM
Subject: RE: [TRNSYS-users] Fw: error message in calling matlab from trnsys

Rekiyat 

 

I does not matter which version do you have type 155 is planned to work with
all versions (I think). But the problem is for some versions you have to
rebuild dll file again.

Anyway, the only thing that I can do is sending you two off my dll with the
following instruction.

 

1-     As attached you can find two folder (old and new) 

2-     First download these two on you desktop

3-     Then go to C:/Trnsys/exe and cut the file type 155.dll (your original
dll file) from this folder to a safe place

4-     Copy the old  " Type 155.dll" which I sent you instead of your
original dll 

5-     Open the file Calling Matlab-MultipleUnits.tpf (located in
c:/Trnsys/example/calling_matlab/) 

6-     If you was able to run this file without error that means your
problem is solved 

7-     If not replace the second dll which I sent it to you " new folder" (

8-     If none of this two dll files solve the problem replace your original
type 155 dll which you have already put in a safe place.

 

Hope it helps

 

Regards

Mehdi

 

 

  _____  

From: Rekiya Suleiman [mailto:omohu_s at yahoo.com] 
Sent: 22 February 2011 06:29
To: Mehdi Shahrestani
Subject: Re: [TRNSYS-users] Fw: error message in calling matlab from trnsys

 

Dear Mehdi

Thanks a lot for your mail, I have Matlab2006a. could this possibly be the
reason for the error message.

Thanks again.

 

Rekiyat


 

 

  _____  

From: Mehdi Shahrestani <mahdishahrestani at yahoo.com>
To: Rekiya Suleiman <omohu_s at yahoo.com>
Cc: trnsys-users at cae.wisc.edu
Sent: Mon, February 21, 2011 10:58:25 PM
Subject: RE: [TRNSYS-users] Fw: error message in calling matlab from trnsys

Dear Rekiyat

 

Couple of months ago I had the same problem. It should be related to the
type155 dll file which calls Matlab. 

This file some times is not compatible with your Matlab version.

Anyway, I have this dll for Matlab 2009a if you have the same version it
could solve the problem.

Please let me know you matlab version.

 

Regards

Mehdi

 

 

 

  _____  

From: trnsys-users-bounces at cae.wisc.edu
[mailto:trnsys-users-bounces at cae.wisc.edu] On Behalf Of Rekiya Suleiman
Sent: 21 February 2011 21:32
To: trnsys-users at cae.wisc.edu
Subject: [TRNSYS-users] Fw: error message in calling matlab from trnsys

 

Dear trnsys users,

Please I am still waiting for help on the forwarded problem, please help!

Thanks

 

Rekiyat

 

----- Forwarded Message ----
From: Rekiya Suleiman <omohu_s at yahoo.com>
To: trnsys-users at cae.wisc.edu
Sent: Fri, February 18, 2011 8:03:40 PM
Subject: error message in calling matlab from trnsys

Hi,

Please can anyone help, I'm still learning to use the trnsys program. I am
trying to use Type155 to call a code written in matlab but I keep getting
the error message 'undefined command/function 'trnInputs'". What can I do to
get out of this.

 

Rekiyat Suleiman

Dept of Mechanical Engineering 

Ahmadu Bello University , Zaria

Nigeria .

 

 

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/attachments/20110223/d1683524/attachment-0001.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: D1.m
URL: <http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/attachments/20110223/d1683524/attachment-0001.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Project7.tpf
Type: application/octet-stream
Size: 54569 bytes
Desc: not available
URL: <http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/attachments/20110223/d1683524/attachment-0001.obj>


More information about the TRNSYS-users mailing list