Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Navigation
- Tecnomatix
- Forums
- Blogs
- Knowledge Bases
- Groups

- Siemens PLM Community
- Tecnomatix
- Plant Simulation
- Interesting calculation "feature" in PlantSimulati...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted
#

Interesting calculation "feature" in PlantSimulation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-28-2015 08:37 AM

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:

is

do

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

Re: Interesting calculation "feature" in PlantSimulation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-28-2015 08:54 AM

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.

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-28-2015 09:07 AM

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

Simulation Engineer

web: www.simsol.co.uk

e-mail: oliver.macfarlane@simsol.co.uk

Re: Interesting calculation "feature" in PlantSimulation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-28-2015 09:16 AM

Then I would have expected:

- to recieving a warning if two not comparable values are related to each other
- 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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-28-2015 09:49 AM - edited 07-28-2015 09:50 AM

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.

Did you like the answer? Then click the Thumbs Up button.

Did the answer solve your problem? Then accept the answer as solution.

Follow Siemens PLM Software

© 2019 Siemens Product Lifecycle Management Software Inc