Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Re: Help for iteration

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-11-2018
01:42 PM

12-11-2018
01:42 PM

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

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-13-2018
10:50 AM

12-13-2018
10:50 AM

@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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-11-2018
03:11 PM

12-11-2018
03:11 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-11-2018
04:11 PM

12-11-2018
04:11 PM

Re: Help for iteration

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-12-2018
03:42 AM

12-12-2018
03:42 AM

Re: Help for iteration

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

So that is still my case haha :'')

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-12-2018
03:45 AM

12-12-2018
03:45 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-12-2018
10:07 AM

12-12-2018
10:07 AM

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)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-12-2018
10:10 AM

12-12-2018
10:10 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-12-2018
11:30 AM

12-12-2018
11:30 AM

Re: Help for iteration

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-12-2018
11:31 AM

12-12-2018
11:31 AM

Re: Help for iteration

Yes I did closed it with the Odesolver…

As you can see in my attached picture.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

12-12-2018
02:04 PM

12-12-2018
02:04 PM

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?