Page 1 of 1
Usage of IF, ELSE statement in mathematical expression editor
Posted: Fri Jun 22, 2018 3:15 pm
by jankolino
Hi,
could someone provide me some example with if else statement in mathematical expression editor.
What I am trying to do:
if(scalar<0.5){
density = ...
}
else{
density = ...
}
And it doesnt work.
Thanks
Re: Usage of IF, ELSE statement in mathematical expression editor
Posted: Fri Jun 22, 2018 5:52 pm
by rodion
Hi,
Unfortunately these things never worked in my simulation on Windows. Try using the file cs_user_physical_properties.f90 for your custom physical properties. You can find several examples in the folder \SRC\EXAMPLES
Best regards,
Rodion
Re: Usage of IF, ELSE statement in mathematical expression editor
Posted: Mon Jun 25, 2018 12:58 pm
by Yvan Fournier
Hello,
What do you mean never work ? Syntax refused by GUI or execution error. ?
Regards,
Yvan
Re: Usage of IF, ELSE statement in mathematical expression editor
Posted: Mon Jun 25, 2018 8:47 pm
by jankolino
For me, the GUI never accepts my code.
Re: Usage of IF, ELSE statement in mathematical expression editor
Posted: Mon Jun 25, 2018 11:05 pm
by Yvan Fournier
Hello,
The expression interpreter should be OK for already-defined cases, as the test suite has been tested on Windows and many cases include MEI expressions, but I wonder whether there might be a Windows-specific issue with the way the GUI and the expression evaluation test program communicate... If this is the case, a "cheat" directly editing the xml file should be ok, and a simple workaround would be to not check the syntax in the GUI. This would be easy to test on Linux, but not so easy with the Windows version, which uses a "frozen Python" distribution method, where editing a simple Python file is not possible...
Could you provide a simple expression you tried on Windows (which fails) so I can test it on Linux ? Also, if you are running on Windows 10, the Linux subsystem for Windows may be a good option to have a full "linux-like" install that plays nice with debugging tools.
Best regards,
Yvan
Re: Usage of IF, ELSE statement in mathematical expression editor
Posted: Tue Jun 26, 2018 2:23 pm
by Luciano Garelli
Hello,
Here is an example of use (linux version),
jankolino wrote: Mon Jun 25, 2018 8:47 pm
For me, the GUI never accepts my code.
Your "scalar" is computed inside the MEI or it is a variable of your problem. Did you check that it exist in the predefined symbol list.
Regards,
Luciano
Re: Usage of IF, ELSE statement in mathematical expression editor
Posted: Tue Jun 26, 2018 11:06 pm
by Yvan Fournier
Hello,
I'll add that I just tested the editor validation in the GUI under Windows and it seems to work.
So the issues jankolino mentions are probably due to syntax errors. The syntax is almost identical to that of the C language, with the exception of the "x % y" operator being "mod(x, y)" under the MEI.
Best regards,
Yvan
Re: Usage of IF, ELSE statement in mathematical expression editor
Posted: Tue Aug 21, 2018 12:01 pm
by jankolino
Thanks to all replies. Sorry I didnt answer earlier, but I got to make it work. It was a problem on my side.