how to repeat a cycle in groovyBC
hello
I want to repeat a time cycle boundary condition for about 10 cycles.as its obvious all things should repeat from first at the end of each cycle.how can I define a time like "virtual time" that can be add to real time without need to calculating time manually.how can I perform that?each cyle takes a small time period like .002s. thank you for replying and all advises are appreciated. thanks. |
Quote:
|
thanks!but i can't understand how should i use % operator in a groovyBC condition for repeating a cycle of groovyBC conditions from starting.i should use it at the end of first time cycle?how?could you give or point me to an example?thank you very much!
|
I think this should get you started in learning how to work with modulo operators.
http://en.wikipedia.org/wiki/Modulo http://en.wikipedia.org/wiki/Modulo_operation The basic thing you want to to is something like "primetime=time%period" |
Quote:
|
thank you both Bernhards!
my case is like it: Code:
fractionExpression "(0<=time()&&time()<=t1)||(t1+c1<=time()&&time()<=t1+c2)||(t1+c3<=time()&&time()<=t1+c4)||(t2+c1<=time()&&time()<=t2+c2)||(t2+c3<=time()&&time()<=t2+c4)||(t3+c1<=time()&&time()<=t3+c2)||(t3+c3<=time()&&time()<=t3+c4)||(t4+c1<=time()&&time()<=t4+c2)||(t4+c3<=time()&&time()<=t4+c4)||(t5+c1<=time()&&time()<=t5+c2)||(t5+c3<=time()&&time()<=t5+c4)?1:0"; the conditins are the same but for convergency they should repeat 20 cycles. then how can I write them by % modulo?since times are floats. is something like this correct?(only first condition doesn't repeat) Code:
fractionExpressin "(0<=time()&&time()<=t1)||(t1+c1<=time()%(t1+c4)&&time()%(t1+c4)<=t1+c2)||(t1+c3<=time()%(t1+c4)&&time()%(t1+c4)<=t1+c4) thanks. |
Quote:
I know what your next posting is going to be: it asks for a dictionary file. There ARE example files in the Examples. Copy and adapt one |
thanks bernhard.you are right!i wanted to ask how use it and where an example is!
I'll do and will ask again! |
bernhard could you tell me if the way i wrote the conditions are right or not?
Thank you. |
Quote:
But, is your question either of the following 1. Did I implement my equation correct? 2. Did I implement the correct equation? The answer to 1: Does it work? Do you get errors? Why do have doubts? The answer to 2: See the above answer by Gschaider. We will not check this for ever. |
thanks.yes!
i dont have enough time to learn a new tool. None of them! I just transformed one set to second.first set is correctly working(my question definitly) is:is second equivalent to the first? |
suppose we have two range of time: t1<t<t2 and t3<t<t4
how we can combine these two into one expression according to the % operator you had said? thanks for help. |
You can't. You can use it for a periodic signal.
Suppose you have a function f(t) denoting a single period of what you want, say, between t=0 and t=p. Also, f(t) itself is not periodic. Simple example f(t)=t. Putting in f(t) will give you a continuously increasing value f(t%p) will give you a sawtooth pattern: http://www.wolframalpha.com/input/?i=plot+t%251 |
thank you for nice and complete explaining.I want to do same work when time is t1<t<t2,t3<t<t4,t5<t<t6,etc.when t2-t1=t4-t3=t6-t5 and t3-t1=t4-t2=t5-t3=... mean the range dimensions and their distance are equal.
for example 1<t<2,3<t<4,5<t<6,... there exist same BC fr all of them. i'm mixed up how to map them into 1<t<2 in spite of its simplicity. is it possible that 1<t%2<2 can be true?or it can't be done by the method of reminders? thank you for taking your time. |
Define your f(t) for t in the range 0 to 2. Then use f(t%2).
Suppose your function is 0 for 0..1, 2..3, 4..5 and 1 for 1..2, 3..4 and 5..6 etc, then you can do something like f(t)=(t%2)>1&&(t%2)<2. Good luck! |
Dear OF-users,
I use a groovyBCFixedValue type BC for the inlet. With a kind of ramp profile for the velocity. "profile=(1.02*time()+0.03);" I want to repeat the above profile each 0.05s. For example: time(0.05)=time(0) time(0.051)=time(0.001) time(0.052)=time(0.002) ... time(0.1)=time(0) time(0.101)=time(0.001) time(0.102)=time(0.002) ... time(0.15)=time(0) time(0.151)=time(0.001) time(0.152)=time(0.002) ... How can I use the modulo-operator (%) to obtain what I want. Thanks for helping me. Regards, Stephane. |
Dear OF-users,
Has someone already used the modulo-operator (%) successfully? Can someone post a short example ? Help s needed ! Regards, Stephane. |
Quote:
So to generate a "parabolic sawtooth" you might do something like this (I'm using variables to make it clearer - I recommend this anyway). Note that tPeriodic is in the range [0,1) Code:
variables ( If you're unsure if you implemented your BC correctly I recommend using the replayBC-utility before running the actual simulation |
thank you openfoam_user.
I had same question for a long time before but didn't take a useful answer and I thought from answers I received that this is so easy to explain and just I don't figure it out and so disappointed! maybe didn't propound it clearly. anyway what does that expression mean(tperiodic*tperiodic)?is it just an example? but my cycle is somewhat more complicated,if anyone can help time(0.05)=time(0) time(0.051)=time(0.001) time(0.052)=time(0.002) ... time(.075)=time(.025) time(0.1)=time(0) time(0.101)=time(0.001) time(0.102)=time(0.002) ... time(.125)=time(.025) time(0.15)=time(0) time(0.151)=time(0.001) time(0.152)=time(0.002) ... time(.175)=time(.025) it means that pieces are not contiguous and intervals are apart. how can set an arrangement for that? |
Quote:
I don't understand why you're disappointed with getting no answers when you disappoint people by not reading their answers. You've got to live with it that people are getting selective with answering. Even if some kind soul answers one of your questions per day she would only answer half of your questions Quote:
|
All times are GMT -4. The time now is 22:42. |