Cancel
Showing results for
Did you mean:

# Interesting calculation "feature" in PlantSimulation Builder

Hi guys!

I need some poisson distribution values in PlantSimulation 10.1.12. Therefore I was writing myself a small method to recursively calculating them. In particular, I wanted to calculate the integervalue that reaches / exceeds the 80% quantil.

The method looks like following:

`isdo    local v_quantil := -1;    local v_lambda := 14.94545454545455;    local v_result := 0;    repeat        v_quantil := v_quantil + 1;        v_result := v_result + (pow(v_lambda, v_quantil) / gamma(v_quantil + 1)) * exp(-v_lambda);    until v_result >= 0.8;end;`

The repeat loop is not performed as often until the sum is reached, instead it leaves immediately with v_result = 0 and v_result >= 0.8 set to true! When line 21 is changed to:

`local v_result := 0.0;`

everything works absolutely normal.

4 REPLIES 4
Highlighted

# Re: Interesting calculation "feature" in PlantSimulation  Siemens Phenom

To declare a floating point variable, the declaration should look like this:

local v_result : real := 0;

or

local v_result := 0.0;

If you write

local v_result := 0;

you actually declare an integer variable. So the places behind the decimal point will be cut off.

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

# Re: Interesting calculation "feature" in PlantSimulation  Solution Partner Genius

Hi Mak,

Your first problem is happening because you have set your local variables in the do section. This is not directly a problem but it means that v_quantil and v_result are set to integers as they don't have any decimal point. This then causes problems in your code. So when it checks the until, PlantSim will assume that 0.8 is actually 0 as v_result is an integer.

You can solve this by either setting the variables under IS and therefore setting their type or change v_result to 0.0 in your current code.

Your other problem does seem to be because PlantSim is can't cope with the large numbers. At the 135th iteration pow(v_lambda, v_quantil) is to the power 307 and gamma(v_quantil + 1) is to the power 230! Both incredibly large numbers so can understand why PlantSim might be having issues.

Ollie

Oliver MacFarlane
Simulation Engineer
web: www.simsol.co.uk
e-mail: oliver.macfarlane@simsol.co.uk

# Re: Interesting calculation "feature" in PlantSimulation Builder

Then I would have expected:

1. to recieving a warning if two not comparable values are related to each other
2. to recieving an information, if a limitation is reched / exceeded especially when nothing is written in the manual / online help about

instead of leaving the user alone while looking for bugs.

# Re: Interesting calculation "feature" in PlantSimulation  Siemens Phenom

I tried your code in the most recent Plant Simulation version 12.1. When you apply the source code, you will get a warning that you compare an integer value with a floating point value that has places after the decimal point.

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.