Saarland University
Lehrstuhl für Automatisierungstechnik

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> assign different values to a vectorial component's parameter
David
post Sep 1 2007, 03:38 PM
Post #1


Newbie
*

Group: Members
Posts: 9
Joined: 26-January 07
Member No.: 385



Hi Florian,

thank you very much! I am happy to know this feature now.
david.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
wagner
post Aug 31 2007, 08:38 AM
Post #2


Administrator
***

Group: Root Admin
Posts: 121
Joined: 13-March 06
Member No.: 1



Hello David,

I replaced the wrong file with the correct Modelica script. Sorry for the mistake.

Florian
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
David
post Aug 31 2007, 08:27 AM
Post #3


Newbie
*

Group: Members
Posts: 9
Joined: 26-January 07
Member No.: 385



Hello Carsten,

thanks for your help: it works! Unbelievable simple.
I tried so much combinations in the assigning line but not this very reasonable one.
Thanks a lot.

Regards
david.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
David
post Aug 31 2007, 08:03 AM
Post #4


Newbie
*

Group: Members
Posts: 9
Joined: 26-January 07
Member No.: 385



Good morning Florian,

I think you saved the same model-file two times accidentally. There is no script file to be found (by me). I am curious what's in there ; )

Thank you,
david.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
wagner
post Aug 31 2007, 06:50 AM
Post #5


Administrator
***

Group: Root Admin
Posts: 121
Joined: 13-March 06
Member No.: 1



Hello David,

attached to this post you'll find a simple model and a script that assigns some parameters before simulation.

To use the script load your model and before running the simulation start the script. In the script the parameters are assigned. Then start the simulation in the ordinary way.

In Dymola you can start the script by calling @Scriptname.mos in the command window on the simulation screen. I don't know how it works in other simulation environments.

In the sample script the parameter values are calculated in a for loop. It's also possible to load the parameter values from a file.

All Modelice IDE's have a pool of functions that can be used in Modelica sripts. In Dymola you get the list of available functions by calling listfunctions() in the command window. In a Modelica script you can use all ordinary Modelica functions (also user defined ones) and the functions of the Script function pool.

Play a little bit around with Modelica scripts. It's a really powerful feature which is rarely known by many Modelica users.

Regards

Florian


Attached File(s)
Attached File  CarRaceExample.mo ( 567bytes ) Number of downloads: 263
Attached File  AssignParameters.mos ( 57bytes ) Number of downloads: 300
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Carsten
post Aug 31 2007, 06:49 AM
Post #6


Advanced Member
***

Group: Members
Posts: 53
Joined: 5-July 06
From: Germany
Member No.: 18



What's about creating a parameter array of start values, which you might fill by upper and lower storage temperature
.
QUELLTEXT
parameter SI.Temperature T_01 = 300;
parameter SI.Temperature T_0n = 280;
parameter SI.Temperature T_0Array[n] = {T_01 + (T_0n-T_01)/(n-1)*i for i in 1:n};


and then you can modify your start values in the component by:
QUELLTEXT

Layer layer[n](T_0=T_0Array);


its that what you want (you even can edit the array by hand)?

regards
Carsten

User is offlineProfile CardPM
Go to the top of the page
+Quote Post
David
post Aug 30 2007, 08:10 PM
Post #7


Newbie
*

Group: Members
Posts: 9
Joined: 26-January 07
Member No.: 385



Hello Florian,

thank you. But I am sorry, I don't know how to do this. Could you please give me a little hint?
Thank you.

Regards,
david.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
wagner
post Aug 30 2007, 02:19 PM
Post #8


Administrator
***

Group: Root Admin
Posts: 121
Joined: 13-March 06
Member No.: 1



Hello David,

you could write a Modelica script that assigns the parameter to the different layers before simulation is started.

Regards

Florian
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
David
post Aug 30 2007, 12:58 PM
Post #9


Newbie
*

Group: Members
Posts: 9
Joined: 26-January 07
Member No.: 385



Dear community,

a little Modelica-programmers question:

I work on a model for a stratified storage for hot water. It exists of n "layers" of water which are instantiated by creating a vector-component layer[n] of the type Layer

CODE
Layer layer[n]


and are connected within the equation area by a for-loop.

CODE
for i in 1 : n-1 loop
connect(layer[i].out, layer[i+1].in);
end for;


The layers have a parameter for their start-temperature. Until now I commit the same start-temperature to all layers by

CODE
Layer layer[n](each T_0=T_0);


But in real life each layer starts with it's own temperature so I would like to commit different start-temperatures to different layers.

Do you have any idea how to do this?

Thank you!
david.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 19th November 2019 - 03:06 AM