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
Usage of IF, ELSE statement in mathematical expression editor
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
Re: Usage of IF, ELSE statement in mathematical expression editor
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
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
-
- Posts: 4251
- Joined: Mon Feb 20, 2012 3:25 pm
Re: Usage of IF, ELSE statement in mathematical expression editor
Hello,
What do you mean never work ? Syntax refused by GUI or execution error. ?
Regards,
Yvan
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
For me, the GUI never accepts my code.
-
- Posts: 4251
- Joined: Mon Feb 20, 2012 3:25 pm
Re: Usage of IF, ELSE statement in mathematical expression editor
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
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
-
- Posts: 284
- Joined: Fri Dec 04, 2015 1:42 pm
Re: Usage of IF, ELSE statement in mathematical expression editor
Hello,
Here is an example of use (linux version),
Regards,
Luciano
Here is an example of use (linux version),
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
-
- Posts: 4251
- Joined: Mon Feb 20, 2012 3:25 pm
Re: Usage of IF, ELSE statement in mathematical expression editor
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
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
Thanks to all replies. Sorry I didnt answer earlier, but I got to make it work. It was a problem on my side.