Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Different data in different months

Different data in different months

Hi I´m a Modelica starter and now I need to write a program with different inputs in different months.

The only way I can think of is to use " if " statement, which would be very long.

Is there any other way to achieve this function?

Thanks.

Re: Different data in different months

Hi!

You cannot use if-statements like that. Modelica only use IF-satements for choosing constants to variables, not choosing which equation you want to use.

Think mathematically! 

Re: Different data in different months

By inputs I mean flow rate. The flow rate is different in different months. They are just numbers not equations.

I did like "if mod(time,365)>=0 and mod(time,365)<31 then Q=**" as the input for January and so on.

It works. But to cover a whole year 12 ifs must be written. So I'm thinking there must be an easier way to do this. However I'm just a starter...

Can you help me with it if you know any?

Thx

Re: Different data in different months

Maybe what you want is a TimeTable for your input.  It takes a table of times and values and outputs the value as the simulation progresses.  You would need to convert months to seconds of the year. 

Re: Different data in different months

So if I have the same number for the entire month, I just need to put the smoothness as ConstantSegments? I'll try it! Thanks!

Re: Different data in different months

Put in an entry for both the start and end of the month that are the same.  That way it will be constant during the month and change at the end.  If January is 31*24*60*60 seconds long, you could do:
table=[0 10
2678400 10
2678401 20
5097600 20
...

Then for the first 2678400 seconds the output would be 10, then, in 1 second it will change to a value of 20 and hold that value for all of Feb. etc.

There are 0 guests and 0 other users also viewing this topic
You are here: