Skip to main content
1-Visitor
December 11, 2018
Solved

Help for iteration

  • December 11, 2018
  • 3 replies
  • 13555 views

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

Best answer by AlanStevens

@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

3 replies

23-Emerald I
December 11, 2018

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.

1-Visitor
December 12, 2018

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.

23-Emerald I
December 12, 2018

@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.

23-Emerald IV
December 11, 2018

Maybe you should look here.

https://community.ptc.com/t5/PTC-Mathcad/Integration-Solver/m-p/578494#M183033

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

 

Success!
Luc

1-Visitor
December 12, 2018

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

So that is still my case haha :'')

23-Emerald I
December 12, 2018

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

Capture.PNG

(set ORIGIN to 1)