Time Integral Log Out | Topics | Search
Moderators | Register | Edit Profile

FlexPDE User's Forum » User Postings » Time Integral « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Mohammad Rahmani (mrahmani)
Member
Username: mrahmani

Post Number: 17
Registered: 10-2004
Posted on Sunday, December 05, 2004 - 07:02 am:   

There is an example in FlexPDE sample folder called tintegral.PDE
( FlexPDE4\Samples\misc\tintegral.pde). A history plot shows the
the values of " tintegral(1) " which is equal to "t". Considering the
interval of integration (-0.5 to 19) you expect a linear graph
but if you look at the output you will see the value is 0 at t=-0.5 and
the final value is (19.25) for t=19. For clarity you can export the result to a file
as follows:
history(t1) as "Tintegral(1)" export format "#t#b#1" File="Tint.txt"

and you will see the following values.
-------------------------------------------------------------
FlexPDE Version 4.2.4 12:54:26 Nov 17 2004
tintegral-R0.pde 11:25:41 12/5/04
Title: Tintegral(1)
Time 19
}
-0.5000000000 0.
-0.4998313120 -0.2496626239
-0.4996626239 -0.2496626239
-0.4994939359 -0.2494939359
-0.4992577727 -0.2492577727
-0.4989271441 -0.2489271441
......................
......................
18.500000000 18.75
18.602938913 18.852938913
18.705877827 18.955877827
18.808816740 19.05881674
18.911755653 19.161755653
19.000000000 19.25

Is it because "t" should start from 0 or there is another reason?

/Mohammad
Top of pagePrevious messageNext messageBottom of page Link to this message

Mongi Mansouri (mongim_pde)
Member
Username: mongim_pde

Post Number: 31
Registered: 11-2003
Posted on Sunday, December 05, 2004 - 04:17 pm:   

Mohammad,
U're right. I think this is a glitch that needs to be fixed. I tried the same sample with the below lines added, and its gives the expected result for t2. It seems that if u dont fix time step, it does not compute the integral correctly. In addition, without the if-statement, the initial value of the integration is always wrong but all other value are correct.

Hope this will shed some light as to the problem and how to fix it.

/Mongi

Here are the lines I added to the sample pde:

select
fixdt !! this goes before variable declaration.

definitions
..........................

t0=-0.5; tf=19; tstep=0.5;

t1 = time_integral(1.0);
!! t1 has error at initial point.

t2 = if(t>t0) then time_integral(1.0) else t0; !! t2 gives correct integral.
..............

time t0 to tf by tstep

histories
history(t1, t2) as "Tintegral(1)" export format "#t #1 #2" File="Tint.txt"


Top of pagePrevious messageNext messageBottom of page Link to this message

Robert G. Nelson (rgnelson)
Moderator
Username: rgnelson

Post Number: 273
Registered: 06-2003
Posted on Monday, December 06, 2004 - 03:40 pm:   

FlexPDE uses a two-step integration method in time. This requires that the first timestep be treated specially. Apparently there is an error in computation of the tintegral over the first timestep if the start time is not zero. (Probably the code assumes a zero start time.)

I will correct this in the next maintenance release.

In the meantime, you can cure the problem by starting at time=0.
Top of pagePrevious messageNext messageBottom of page Link to this message

Mohammad Rahmani (mrahmani)
Member
Username: mrahmani

Post Number: 18
Registered: 10-2004
Posted on Monday, December 06, 2004 - 10:58 pm:   

Thanks to both you Mongi and Robert.
The method Mongi has proposed cure the first ouput but remains for later time points. Of course by strating from 0 the result are correct.

/Mohammad

Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:

Topics | Last Day | Last Week | Tree View | Search | Help/Instructions | Program Credits Administration