nick262b
Mechanical
- Apr 17, 2013
- 25
Hi everyone,
I have a working version of some ASME design code I have programmed into mathcad but am having trouble trying to figure out if I can use the code to iterate a solution.
There is a variable lets say X that is defined very early on in the code as a user input/initial value and is in this case the only independent variable.
For a given X all other values are calculated based on user inputs and the programmed formulae and it spits out an answer of pass/fail and values etc.
I want the whole sheet to essentially run as a while loop and increment X until the failure criteria are reached so that I can find the maximum values. I understand how to programme small while loops in mathcad but the code calculations are pages long and contain many If statements and huge equations with multiple returns and so this would get messy based on my current way of doing things (using addline command on a single variable). Is there a way I can achieve what I am wanting in mathcad?
In C++ for example each part of the code calculation would be a function and the main programme would simply call these in turn whilst running as a while loop incrementing the function argument X until the specified fail criteria.
before you suggest Excel, I have got this working easily in Excel but need the visual display properties of mathcad to present the work in an easily checkable format for when independent verifiers review the work. Also It would be nice to learn this capability in mathcad if it is possible.
Would one way be redefining all my equations as a function of X and then going from there? is there an easy way of doing this?
Any help that anyone can lend would be much appreciated.
Kind Regards,
Nick
I have a working version of some ASME design code I have programmed into mathcad but am having trouble trying to figure out if I can use the code to iterate a solution.
There is a variable lets say X that is defined very early on in the code as a user input/initial value and is in this case the only independent variable.
For a given X all other values are calculated based on user inputs and the programmed formulae and it spits out an answer of pass/fail and values etc.
I want the whole sheet to essentially run as a while loop and increment X until the failure criteria are reached so that I can find the maximum values. I understand how to programme small while loops in mathcad but the code calculations are pages long and contain many If statements and huge equations with multiple returns and so this would get messy based on my current way of doing things (using addline command on a single variable). Is there a way I can achieve what I am wanting in mathcad?
In C++ for example each part of the code calculation would be a function and the main programme would simply call these in turn whilst running as a while loop incrementing the function argument X until the specified fail criteria.
before you suggest Excel, I have got this working easily in Excel but need the visual display properties of mathcad to present the work in an easily checkable format for when independent verifiers review the work. Also It would be nice to learn this capability in mathcad if it is possible.
Would one way be redefining all my equations as a function of X and then going from there? is there an easy way of doing this?
Any help that anyone can lend would be much appreciated.
Kind Regards,
Nick