CFD Online Discussion Forums

CFD Online Discussion Forums (
-   CFX (
-   -   Creating, loop or iteration using expression edito (

Jan July 17, 2003 05:45

Creating, loop or iteration using expression edito
Hi all, I am modelling a reaction between metal and hydrogen. I have a modified arrhenius equation for determining rate of the above reaction. I am modelling the above reaction in a tricky way. The hydrogen is not reacting with metal but it is entering the domain and disappearing at the rate given by the modified arrhenius expression and this arrhenius expression takes into account the properties of the metal that I am using. Now, coming to my question.

I have a term like the following in the arrhenius expression.

(1.0 - (x/1.85))

In the above expression 1.85 represents the weight percentage of total amount of hydrogen which the metal can hold (i.e., 100 gm of metal will hold 1.85gm of hydrogen). This means the reaction will end once this number is achieved (when the x=1.85 then the resultant term is 1.0 and the whole term spells out to zero and the modified arrhenius expression is zero).

The reaction goes like this, at the first iteration the hydrogen enters and reacts(not really reaction but it disappears at the rate given by the rate expression which I explained above). Then x has some value, perhaps x=0.01. Then in the second iteration this x will be say again 0.01. During the beginning of the third iteration I want the x to have the value of (0.01(first iteration) + 0.01(second iteration)) 0.02 and not zero(which is the case now). Say after some number of iterations x will have the value of 1.85 and the reaction stops. But this can happen only when I succeed in adding the rate term consecutively to the x after every iteration. For this I need to do something like loop or iteration kind of thing which we do in Fortran or other programming languages.

Can anyone guide me through this? Thanks in advance.


Robin July 27, 2003 23:34

Re: Creating, loop or iteration using expression e

You should use an additional variable.


Jan July 28, 2003 04:53

Re: Creating, loop or iteration using expression e
Hello Robin, I didnt understand this additional variable concept. I am trying to make it something like one dimensional array. In which the x term is a function of time. But I dont think the expression editor can take the x in the form of x(t) and x(t-1). Let me write a bit in detail. My modified arrhenius expression looks like the following ArrRate = * (1-x/1.85) * * -there are lot of other terms.

this x is a ratio of weight. and it will not go more than 1.85(I explained in original message).

this x should be computed from ArrRate(t-1) and should be put into ArrRate(t). Besides this I also have to sum up the x for all the previous timesteps to compute my present timestep. Is there a way to deal with these arrays in expression editor? thanks in advance.


Robin July 28, 2003 11:01

Re: Creating, loop or iteration using expression e
Hi Jan,

Okay, I see. So an additional variable would not help in this case.

You can do what you are asking by creating a user CEL function which executes your own user fortran routine. For futher assistance, I suggest you contact technical support.

Regards, Robin

All times are GMT -4. The time now is 21:18.