Taking derivatives of an array variable Log Out | Topics | Search
Moderators | Register | Edit Profile

FlexPDE User's Forum » User Postings » Taking derivatives of an array variable « Previous Next »

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

Igor Bolotnov (boloti)
New member
Username: boloti

Post Number: 2
Registered: 12-2007
Posted on Tuesday, March 11, 2008 - 11:37 am:   

Hello!

I'm writing a code with 8 similar equations. (FlexPDE 5.0.19 1D Professional).

Since it is impossible to define array variables, I do it this way:

variables
u(threshold=2.0)
k1(threshold=2.0)
k2(threshold=2.0)
k3(threshold=2.0)
k4(threshold=2.0)
k5(threshold=2.0)
k6(threshold=2.0)
k7(threshold=2.0)
k8(threshold=2.0)

definitions

K = array(k1, k2, k3, k4, k5, k6, k7, k8)
TK = k1+k2+k3+k4+k5+k6+k7+k8

Then, I have a problem:
dx(TK) or dx(k1) results in a proper derivative while an attempt to apply dx(K[1]) results in zero value.

So, I'm missing some dx terms in my equations when I specify the Right Hand Side of the equations as:

! Diffusion term
D(j) = dx(nu_cl*dx(K[j])) ! This one does not work!

! Turbulent Diffusion term

ARG0(j) = nu_T(j)*dx(TK) ! This one works!
TURD(j) = dx(ARG0(j))

RHS(j) = P(j) - eps(j) - epsY(j) + TR(j) + D(j) + TURD(j)

equations
u: lambda*rho*dt(u) = div(rho*(nu_cl+TNu_T)*grad(u)) - dPdx
k1: lambda*dt(k1) = RHS(1)
k2: lambda*dt(k2) = RHS(2)
k3: lambda*dt(k3) = RHS(3)
k4: lambda*dt(k4) = RHS(4)
k5: lambda*dt(k5) = RHS(5)
k6: lambda*dt(k6) = RHS(6)
k7: lambda*dt(k7) = RHS(7)
k8: lambda*dt(k8) = RHS(8)


Do you know how to get the derivative values from arrays defined above? (without tediously specifying each equation separately which may result in a bunch of typos)


I have removed all irrelevant (IMHO) information, please let me know if I missed to provide anything.

Thanks a lot!
Top of pagePrevious messageNext messageBottom of page Link to this message

Robert G. Nelson (rgnelson)
Moderator
Username: rgnelson

Post Number: 1080
Registered: 06-2003
Posted on Tuesday, March 11, 2008 - 01:15 pm:   

ARRAYS in FlexPDE version 5 are quite restricted. The facility was added primarily to allow compacting of expressions in domain definition.

ARRAY components must be parse-time constants. FlexPDE cannot handle arrays of variables.

Your constructs like RHS(j) are really parameterized definitions, and as such are expanded as function calls. But this won't work to access an indexed array of variables.

You'll have to simply use copy and paste to replicate copies and manually patch in the variable number.

Sorry.

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