View Full Version : One system with two coordinates

04-18-2007, 10:00 AM
We would like to solve a system of equation that describes a rotating disk
electrode system. Due to the singularity problem pointed out in the literature, the approach we would like to take is to devide the system into two regions: the equations in one region will be expressed in cylindrical coordinate and those in the other will be expressed in rotational elliptic coordinate. A continuous boundary condition will be used to link these two regions together. Can this be done using PDE2D? If so, please show instructions.

04-18-2007, 10:34 AM

I think you will want to create two separate PDE2D programs. Let's call the common boundary (interface between the two regions) B1; then program A should set a boundary condition U=fa(x,y) on B1, where fa is defined as a Fortran function which sets some initial values the first time you run program A, but every subsequent time it reads the solution on B1 (and interpolates it to (x,y)) written out by program B. Then program A should write out its solution along B1 after solving the problem, this is easily done in subroutine POSTPR. Similarly, program B will set a boundary condition U=fb(x,y) on B1, where fb reads the solution on B1 written out by program A, and then program B (in POSTPR) writes out its solution after solving the problem. So you will have to iterate back and forth between the two programs until (hopefully) you get convergence.

One tip: since fa(x,y) (and fb) will be called many times (with different values of x,y), you don't want to read the previous solution (and interpolate) every time fa/fb is called, you want to read and save the old solution (on B1) in an array, on the first call only, but interpolate this to (x,y) every call. You might want to look at the bottom of prepared example ex5.f to see an easy way to do this, and follow this model. In fact, PDE2D provides a mechanism (illustrated by the communication between prepared examples 4 and 5) for doing all this automatically (ie, reads the solution the first call, interpolates it to (x,y) every call), but I don't think you can use this automatic feature for your problem, because of the different coordinate systems (or maybe you can, I'm not sure).

It is pretty easy to do non-standard things like this with PDE2D, because once you have created your program in an interactive session, you simply have a Fortran program which calls PDE2D library routines, so you have all the flexibility of Fortran at your disposal, just like you do in using the IMSL library. Except you don't have to write the initial program yourself, that is done automatically by the interactive driver.


Granville Sewell

04-18-2007, 10:44 AM
Actually, I just realized that looking at the end of ex5.f won't help much, the reading of the solution and interpolation to (x,y) is hidden in subroutine TDPT. But basically you just need some structure like:

function fa(x,y)
dimension U(n,m)
data iflag/0/
if (iflag.eq.0) then
iflag = 1
(read solution into array U)
(interpolate fa at (x,y) using array U)

this ensures that you don't re-read the previous solution (on B1) every call to fa.

Granville Sewell

04-18-2007, 02:11 PM
Thank you. I understand what you say, but there is still a question:

Can the iteration between the two programs be done automatically or I need to do it manually? My understanding from your examples is that it needs to be done manually. Just want to make sure.


04-18-2007, 02:26 PM

Well, it could be automated in the sense that you can create the executables for each program (remove the line in RUNPDE2D.BAT that deletes the executable at the end), then create a Unix script file (or *.BAT file if you're running Windows, I guess you are) that executes the two programs alternately.

It is possible to solve many problems in one program, by setting NPROB > 1 and making the problem parameters vary with IPROB (IPROB=1...NPROB). But for this problem, the two problems are so different I think you have to create separate programs for them.