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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to use the root command in a program

cbentivoglio
6-Contributor

How to use the root command in a program

Hi everyone, I am having some trouble with this program. My aim is to find a temperature (by using the command root) in a program, can anyone help me?

ACCEPTED SOLUTION

Accepted Solutions

Salve Claudio Bentivoglio,

dovrei conoscere a fondo il problema per essere certo della soluzione.

Comunque, quella che segue potrebbe andare bene?

Batch Distillation.jpg

Distinti saluti.

F. M.

View solution in original post

7 REPLIES 7
LucMeekes
23-Emerald III
(To:cbentivoglio)

You've probably run into the automatic labelling trap of Mathcad Prime:

Notice that my cursor (short vertical blue line) is on the T.b[0 variable where it is assigned the value of T.b.B0 (of which I could not find a definition, so that may be yet another problem). The label (see the ribbon: 'Labels', 3rd from top-right) of this T.b[0 variable is 'Variable'. If you move the cursor to the offending item T.b[i-1 inside the argument list of the root function you see that the label of that item is not 'Variable', but '(-)'. Now both items refer to an element of the vector T.b (the first to its element with index 0, the other to the element with index i-1. The labels are different, so the arrays are different, and that's not your intent, I guess. You can correct this by manually changing the label of T.b[i-1 to be a 'variable' as well. then this problem should be out of the way.

Unfortunately I cannot do it, because I'm limited to Prime Express (no programming or solve blocks allowed). But if you (still) run into more issues, don't hesitate to come back here.

Success!
Luc

LucMeekes
23-Emerald III
(To:LucMeekes)

Oh, there's one other thing.

The 300 and 400 K limits don't use K(elvin) as a unit, but K as a variable instead. If they were units, they'd be as blue as the K(elvin) inside the solve block just above your program. Similar label trap stuff... Similar method of correction.

Luc

Thanks for your quick response.
I've changed the label of both the K (units) and the Tb.i-1 (variable) but the program still doesn't work. Also I assigned the value of Tb.B0 inside the solve block! Could there be any other problems (mostly regarding the use of the root function)?

LucMeekes
23-Emerald III
(To:cbentivoglio)

Yes there could be.

Try to see if the root function works with a simple variable, rather than a vector element. Assign T.b[i-1 to a variable Temp (e.g.) before calling root and use that instead inside the root function.

Success!
Luc

LucMeekes
23-Emerald III
(To:cbentivoglio)

You have more problems. The x.B used in the expression as argument to the root function is an array, but it's i'th element x.B[i is NOT an array, and you try to index it with n.

Luc

Salve Claudio Bentivoglio,

dovrei conoscere a fondo il problema per essere certo della soluzione.

Comunque, quella che segue potrebbe andare bene?

Batch Distillation.jpg

Distinti saluti.

F. M.

cbentivoglio
6-Contributor
(To:-MFra-)

Grazie mille! è proprio quello che volevo fare, ma non mi è venuto in mente di creare una funzione della temperatura all'interno del programma!
Ti allego il programma così se vuoi capire quello che stavo facendo puoi farlo. Grazie ancora!

Announcements

Top Tags