|
[Sponsors] |
October 16, 2017, 10:30 |
Add or subtract two variables in TUI
|
#1 |
Member
Tarantino
Join Date: Feb 2013
Posts: 46
Rep Power: 13 |
Hello all
I want to do a simple math in TUI as the following: Code:
(define a pick-a-real "report surface-integrals volume-flow-rate bc1 ,,") (define b pick-a-real "report surface-integrals volume-flow-rate bc2 ,,") (- a b) and I got this error: Error: - (subtract): invalid argument [1]: wrong type [not a number] Error Object: #[compound-procedure] I tried also: Code:
(rpsetvar 'x (pick-a-real "report surface-integrals volume-flow-rate bc1 ,,")) (rpsetvar 'y (pick-a-real "report surface-integrals volume-flow-rate bc2 ,,")) (- x y) and I got this error: Error: eval: unbound variable Error Object: x Anyone know what is the problem and how can I fix it? Thanks. |
|
October 16, 2017, 21:26 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Hello,
you may try this approach Code:
(define (make-new-rpvar name default type) (if (not (rp-var-object name)) (rp-var-define name default type #f))) ; function for creation new variables (make-new-rpvar 'x 0.0 'real) ;define new variable x (rpsetvar 'x (pick-a-real "report surface-integrals volume-flow-rate p ,,")) ; set x value (rpgetvar 'x) ; get x value Best regards |
|
October 16, 2017, 23:20 |
|
#3 | |
Member
Tarantino
Join Date: Feb 2013
Posts: 46
Rep Power: 13 |
Quote:
Hi, thanks for your reply. I think you misunderstood my question. I successfully define the variables, but cannot do the math on those variables! You explain how ca I define variable "x" and assign the volume flow rate of a BC to it. There is no problem in this section. However, how to add a number to "x" for instance. Why (+ x 2) won't work! |
||
October 17, 2017, 01:36 |
|
#4 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Quote:
Code:
(rpsetvar 'x (+ (rpgetvar 'x) 2)) (rpgetvar 'x) Best regards |
||
October 17, 2017, 13:36 |
|
#5 |
Member
Tarantino
Join Date: Feb 2013
Posts: 46
Rep Power: 13 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to add a new variable in the list of variables for MESH ADAPTATION ?? | Tramery | CFX | 3 | September 28, 2011 11:27 |
diffusion Term for add. Variable | Zaktatir | CFX | 9 | July 16, 2011 10:51 |
How to limit a variable | ash | OpenFOAM Running, Solving & CFD | 1 | June 26, 2008 21:32 |
Problem in installation of OpenFOAM | sachin | OpenFOAM Installation | 7 | January 22, 2008 02:40 |
Env variable not set | gruber2 | OpenFOAM Installation | 5 | December 30, 2005 05:27 |