lagging a variable Log Out | Topics | Search
Moderators | Register | Edit Profile

FlexPDE User's Forum » User Postings » lagging a variable « Previous Next »

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

Stephen Heermann (sheermann)
New member
Username: sheermann

Post Number: 1
Registered: 12-2008
Posted on Wednesday, December 03, 2008 - 04:32 pm:   

Is it possible to define a function that uses a variable from the previous time step? For example, I would like to compute a Dirchlet boundary value that is a function of one of the system variables (concentration). However I would also like to define that boundary value at the start of a time step and have it remain constant during the time step in order to maintain computational stability.
Top of pagePrevious messageNext messageBottom of page Link to this message

Marek Nelson (mgnelson)
Moderator
Username: mgnelson

Post Number: 92
Registered: 07-2007
Posted on Thursday, December 04, 2008 - 02:34 pm:   

I don't know why you would want to do this. A lagged parameter definition would make the problem more unstable not less. The method of fully implicit solution used by FlexPDE is the most stable method available.

If you have an example that is going unstable, post it here (or email it to support@pdesolutions.com if it is private) so we can take a look and try to determine what the problem is. There may be some other reason for the unstabililty.

Having said this, you can reference the previous value of a variable using "#1" appended to the variable name. e.g. V#1 would be the previous value for the variable V.
Top of pagePrevious messageNext messageBottom of page Link to this message

Stephen Heermann (sheermann)
New member
Username: sheermann

Post Number: 2
Registered: 12-2008
Posted on Sunday, December 07, 2008 - 06:06 pm:   

application/octet-streamdensity-driven advective transport in a porous medium
ddf1b_2.pde (4.6 k)

Maybe lagging isn't the solution. Since I am new to Flexpde I welcome any input.
I am solving a pde for density-driven flow created by ethanol moving from a gasoline to an adjacent water body. As the ethanol partitions into the water, the density of the gasoline decreases creating density driven flow. I ahve no problems with the solution in that domain. However, I am also trying to simulate ethanol concentration changes in the water via an ordinary differential equation (which flexpde seems to be OK with if it is declared as a global variable -- note if the equation,
dt(C_aq)*V_aq = Q_etoh-Qaq*C_aq, can be integrated outside of the set of equations please let me know how). Moreover I would like the rate of mass transfer from the gasoline to the aqueous phase to be dependent on the aqueous-phase ethanol concentration.

However, the solver fails to solve the equations when I try to (directly or indirectly as C_bndy) include C_aq in the boundary condition.

Note that in the attached file, I have temporarily substituted an explicit definition for C_bndy. Ultimately I would like something like the preceeding commented-out statement to work.

Note that I tried to use ustep to get past the first few time steps before going implicit. Oddly, this did not work, even for the first time step.

I am open to all ideas including restructuring the whole program.

Thanks



Top of pagePrevious messageNext messageBottom of page Link to this message

Marek Nelson (mgnelson)
Moderator
Username: mgnelson

Post Number: 94
Registered: 07-2007
Posted on Monday, December 08, 2008 - 07:05 pm:   

What exactly do you mean by "the solver fails"? I ran the script and it did not seem to have a problem. But I don't know what you are expecting as an answer.

Also, what version of FlexPDE are your running and on what operating system?
Top of pagePrevious messageNext messageBottom of page Link to this message

Stephen Heermann (sheermann)
Junior Member
Username: sheermann

Post Number: 3
Registered: 12-2008
Posted on Tuesday, December 09, 2008 - 12:34 pm:   

Sorry , I didn't explain the situation well.
On the attached file, I commented out the offending line (line 78)
!C_bndy = (ustep(100-t)*Caq0 + ustep (t-100) *C_aq)/100.
I temporararily replaced this by an alternative line that does not require the use of the vairable C_aq. While the second line works, it is not what I would like to do. If you comment-out the second line and activate line 78, you will see that the program does not allow me to calculate the boundary condition for C as a function of C_aq.

By the solver failing, I mean that the first time step keeps dropping until it reaches 1e-10.

I am running this on Windows XP using two Intel Xeon Core 2 Processors.

Again, my question has much to do with how to handle C_aq. Conceptually it is outside of the grid domain in a well-mixed (homogeneous) aqueous phase. I have tried to represent it as a global variable so that can be integrated by including it as an ordinary differential equation. It is needed as a dependent variable to quantify the boundary condition at z=0 and t>0.
Top of pagePrevious messageNext messageBottom of page Link to this message

Stephen Heermann (sheermann)
Member
Username: sheermann

Post Number: 4
Registered: 12-2008
Posted on Tuesday, December 09, 2008 - 01:24 pm:   

PS

Alot of this is related to confusion with regard to scalar non-distributed variables that need to be tracked with time and/or integrated as a function of time (e.g. C_aq or mass_etoh). If I try to use tintegrate on C_aq if it is not defined as a variable, e.g
C_aq = tingegrate(Q_etOH/V_aq - Q_aq*C_aq/V_aq)
I get traceback errors
If I try to differentiate mass_etOH, e.g
mass_etOH = vol_integral(C)*poros
Q_etOH = dt(mass_etOH)
the derivative comes out as zero even though I can see from reports that mass_etOH is decreasing.

Top of pagePrevious messageNext messageBottom of page Link to this message

Marek Nelson (mgnelson)
Moderator
Username: mgnelson

Post Number: 95
Registered: 07-2007
Posted on Tuesday, December 09, 2008 - 03:58 pm:   

I ran this on version 5.1.1 with your line 78 defining C_bdry in terms of C_aq and did not have a problem with the first time step.

What version of FlexPDE are you running? There was an error fixed in version 5.0.23 that relates to the GLOBAL VARIABLE dependence on natural boundary conditions.

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