help wanted on function definition ! Log Out | Topics | Search
Moderators | Register | Edit Profile

FlexPDE User's Forum » User Postings » help wanted on function definition ! « Previous Next »

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

junqiao wu (charlesw)
New member
Username: charlesw

Post Number: 1
Registered: 04-2007
Posted on Thursday, April 12, 2007 - 05:05 pm:   

Dear Mr. Nelson and everyone else,

I am a new user. How do I define a function with integration? Such as something like,

f(x)=Integrate(1/(1+Exp(t-1)), (t runs from 0 to x))

so that I can recall the function f(x) later in my Equation ?

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

Robert G. Nelson (rgnelson)
Moderator
Username: rgnelson

Post Number: 812
Registered: 06-2003
Posted on Thursday, April 12, 2007 - 06:20 pm:   

Make fx a VARIABLE with the equation dx(fx)=1/(1+exp(x-1)), and give it a VALUE(fx)=0 BC at the left end.
Top of pagePrevious messageNext messageBottom of page Link to this message

junqiao wu (charlesw)
New member
Username: charlesw

Post Number: 2
Registered: 04-2007
Posted on Thursday, April 12, 2007 - 09:36 pm:   

Robert,

Could you make it a bit clearer by writing down explicitly the script? f(x) is not 0 at x=0.

I want to build f(x) here, and later call values of f(3), f(2*x^2), f(f(x)), etc., in my Poisson's Equation. Thanks a lot!
Top of pagePrevious messageNext messageBottom of page Link to this message

Robert G. Nelson (rgnelson)
Moderator
Username: rgnelson

Post Number: 816
Registered: 06-2003
Posted on Friday, April 13, 2007 - 12:29 am:   

I jumped to the conclusion that "x" indicated a spatial coordinate. Sorry.

1.
If there is a series expansion available for F(x), you could use the SUM function to evaluate the expansion:
DEFINITIONS
F(q) = SUM(...q...)

2.
You could tabulate F(x) and use it as a lookup TABLE. You can use linear or spline interpolation.
Set up your table to use "x" as the table coordinate.
FlexPDE will assume "x" is the space coordinate, but you can fool it by using the EVAL function.
DEFINITIONS
ftable=TABLE("tablefile",x)
f(q) = EVAL(ftable, q,0)

3.
There may be other ways, but I whould need to know how the various uses of f() appeared in the script (whether each form characterized a material, etc).

4.
There is no generic integrate function for arbitrary arguments. FlexPDE is based on the assumption that you are solving PDEs over a material domain with material properties. It is not a general symbolic algebra system. We could implement such a function, but it would be expensive, as the integration would be evaluated repeatedly for each quadrature point in the mesh during each step of the solution. The TABLE approach would be much faster.

Top of pagePrevious messageNext messageBottom of page Link to this message

junqiao wu (charlesw)
Junior Member
Username: charlesw

Post Number: 3
Registered: 04-2007
Posted on Friday, April 13, 2007 - 12:52 am:   

Thanks a lot! I will use the TABLE method.

Just one comment on FlexPDE in general: in physics often times we need to solve potential over some material domains (Div(Grad(V))=rho/epsilon), where the charge distribution (rho) itself depends on the local potential (V) in an integrated form (eg, rho(V)=Integrate[Sqrt(E)/(1+Exp(E-Ef)/kT)),(E, 0,V)]. It would be great if FlexPDE could handle these problems in an algebraic way.

Thanks again!

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