cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

SOLVED
Regular Member

## Help for iteration

Hey guys,

I'm new in Mathcad and I'm doing my thesis now. I have some trouble finding how to do iteration in Mathcad.

So in my file, I have a reactor of 250 m. And I want to know how the concentration changes.

But, I want the simulation to run for >1 cycle. Which means I have to define a way to make the Cout (concentration out) from previous cycle, as a value for the Cin(2) concentration in of the next cycle. These are for both liquid and gas concentration.

So in summary I want to make a loop of :

COlin (x+1) = COlout (x)

COgin (x+1) = COgout (x) + COgin (x)

Help guys 😞

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Help for iteration

@NandaV wrote:

I mean now I have the for loop cycle after the 1st cycle derivation.

No. I just left an example of a single cycle so you could see that changing the Odesolve block to a function didn't alter the calculation.  In the attached I've removed this!

@NandaV wrote:

Also, isn't now the system taking the value from previous x point, so the COlin (x) = COlout (X-1) instead of per cycle?

No. Each cycle covers all values of x before updating the inlet values for the next cycle.  This is because all values of x are considered by the Odesolve function which is called just once per cycle.

Alan

28 REPLIES 28

## Re: Help for iteration

What you have is two coupled first order differential equations.  Your "Given" block is missing its closure.

Given needs to be a closed block, in your case with Odesolve.  Review help on solving differential equations--there should be an example that is directly applicable.

## Re: Help for iteration

Maybe you should look here.

It deals with (what appears to be/almost?) the exact same problem.

Success!
Luc

## Re: Help for iteration

Hey Luc, unfortunately, that is my other account which I forgot the password..

So that is still my case haha :'')

## Re: Help for iteration

Hey Fred,

Thanks for your reply. What do you mean by closed solve block?

Because in that file i'm using the "Given" which means I have the solve block already?

Now i'm just confused in trying to figure out how to loop the result as an input of the next derivation.

## Re: Help for iteration

There's an old method in Mathcad that mimics Euler's approximation to ODE's.  This might work for you.

(set ORIGIN to 1)

Highlighted

## Re: Help for iteration

@SavitriN wrote:

Hey Fred,

Thanks for your reply. What do you mean by closed solve block?

Because in that file i'm using the "Given" which means I have the solve block already?

Now i'm just confused in trying to figure out how to loop the result as an input of the next derivation.

A solve block opens with "Given".

It closes with "Find" or with "Minerr" or with "Minimize", or with :Maximize," or with "ODEsolve" (maybe I've missed a couple.)

Yours doesn't close.

## Re: Help for iteration

Yes I did closed it with the Odesolver…

As you can see in my attached picture.

## Re: Help for iteration

So you should have two functions of the two parameters.  What happens if you type C.O2lSS(2m), or try to plot C.02lSS(x) vs x?

Announcements