how does "Calculate and plot" feature work?

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

how does "Calculate and plot" feature work?

Post by uwestoehr »

While documenting the CCX result object:
https://wiki.freecadweb.org/FEM_ResultShow#Usage

I stumbled over the "Calculate and plot" button. Can anybody please help me how this works and how I can get a plot?

Here is what I already found out:
- I can enter an equation like "x-y" and pressing the button gives me the result in the Min/Max field and colors the result mesh.

But there are many issues i don't understand yet:
- why does "x*x" not give me correct result?
- why is the input "x^2" invalid? Meaning what is the syntax to get a square or square root?
- how can I create a plot?
- open the result dialog, in the equation input, delete for example a character of the comment. As result you get:

Code: Select all

TypeError: user_defined_text() missing 1 required positional argument: 'equation'
This error occurs on every input you make, no matter if it is a valid equation or not.

@NewJoker , @UR_, @user1234, @johnwang can you help me here?
user1234
Veteran
Posts: 3319
Joined: Mon Jul 11, 2016 5:08 pm

Re: how does "Calculate and plot" feature work?

Post by user1234 »

I also tried a little bit and i think, it is not completly fully implemented.

Fist off all, finding the Hints user defined equations was pretty hard, till i regonized, it is in the Taskview under the results.

1.png
1.png (89.88 KiB) Viewed 1192 times

Power functions seems to do not work (see later below), but multiply works seems to work For example vM*vM or 2*vM*vM seems to work.

I thought first, that maybe there is a unit (dimensions) barrier, but x-2*vM*vM*vM seems to work too, which makes no sense. It seems that it only takes the value of the arrays of the result, which is understandable for the first try of implementation. But i can not verify that, since it plots no (color) bar and their values to read. Also you can not pick a result of a node.

2.png
2.png (77.59 KiB) Viewed 1192 times

Also something like (x*x + y*y + z*z)**(0.5) (tried with **, ^ ) does also not work. But it recognize the 1/2, because it parses everytime to 0.5 in the log.

Code: Select all

Syntax error at '*'
0.5

I would let is as it is, since + - * / seems to work. Maybe bernd know more about hat, since, at least i think, he implemented it. But he was not here a pretty long time since he works extremely in the end of the last year to January. (Also i think you know more than i, since you are a core dev).


Greetings
user1234

edit: moved picture, typo
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: how does "Calculate and plot" feature work?

Post by uwestoehr »

user1234 wrote: Sat Jun 04, 2022 7:40 pm Fist off all, finding the Hints user defined equations was pretty hard, till i regonized, it is in the Taskview under the results.
Thanks for having a look. In master i already improved the situation by adding a tooltip to the input field. I also explained now in the Hints user defined equations box the variables P1 to P3.

I had a brief look at the code and there is no plot command. One can also not use the "Histogram" button to plot since the "Calculate" button explicitly sets the result type to "None".

So close before the release, the feature cannot be fixed. I hope that @bernd can have a look later.
For now I will rename the button to "Calculate" since plotting is not done and it is confusing.
user1234
Veteran
Posts: 3319
Joined: Mon Jul 11, 2016 5:08 pm

Re: how does "Calculate and plot" feature work?

Post by user1234 »

uwestoehr wrote: Sat Jun 04, 2022 8:28 pm I had a brief look at the code and there is no plot command. One can also not use the "Histogram" button to plot since the "Calculate" button explicitly sets the result type to "None".
True. What works is, that the color changes. And when i square one point (for example equation vM*vM), then the color changes to that direction, that is seems that the value is squared.


Greetings
user1234
Danial Iskhakov
Posts: 11
Joined: Sun Mar 13, 2022 7:54 pm
Location: Україна/Ukraine
Contact:

Re: how does "Calculate and plot" feature work?

Post by Danial Iskhakov »

Maybe this video can help somehow
phpBB [video]
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: how does "Calculate and plot" feature work?

Post by uwestoehr »

Here is a PR that adds support for the '^' character:
https://github.com/FreeCAD/FreeCAD/pull/6966

I tempt to merge this for the 0.20 release because it is annoying to get a long and cryptic error message with a simple term like "x^2".
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: how does "Calculate and plot" feature work?

Post by uwestoehr »

Danial Iskhakov wrote: Sat Jun 04, 2022 10:15 pm Maybe this video can help somehow
Thanks. This is what I also found out and documented.
Meanwhile I could figure out more. The feature as it is is quite buggy. For example you can perform a calculation like "x-vM" which makes no sense.
However, I added now tooltips and improved the wording to make more clear what the feature is about (will be in FreeCAD 0.20). I also finished the Wiki documentation.
user1234
Veteran
Posts: 3319
Joined: Mon Jul 11, 2016 5:08 pm

Re: how does "Calculate and plot" feature work?

Post by user1234 »

uwestoehr wrote: Sat Jun 04, 2022 10:16 pm Here is a PR that adds support for the '^' character:
https://github.com/FreeCAD/FreeCAD/pull/6966
I tested with the the displacement magnitude to compare:

(x^2 + y^2 + z^2)^(1/2)


The value of the result is the same, the color gradient also. So it seems that works (except there is not unit, but that is known). So thanks for that!


Danial Iskhakov wrote: Sat Jun 04, 2022 10:15 pm Maybe this video can help somehow
I never know that, then a self defined array rises. That can be indeed useful.


Greetings
user1234
Post Reply