Adjoint Equations Log Out | Topics | Search
Moderators | Register | Edit Profile

FlexPDE User's Forum » User Postings » Adjoint Equations « Previous Next »

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

mgnelson
Moderator
Username: mgnelson

Post Number: 186
Registered: 07-2007
Posted on Monday, May 17, 2010 - 02:13 pm:   

I am creating this thread in order to move some previous posts to it.
Top of pagePrevious messageNext messageBottom of page Link to this message

4maitland
New member
Username: 4maitland

Post Number: 1
Registered: 05-2010
Posted on Thursday, May 13, 2010 - 05:42 pm:   

I have a question about a concept that has been nagging me for an answer for some time now. What is meant by an "Adjoint Equation?" I have looked throughout the internet trying to get a match for the A/E. I understand it is not the self adjoint form commonly found DiffEQ texts, so then waht is it? Currently, I copied and edited an idea from one of the sample problems found in the, well, sample problems section. The problem displays a "field map.pde" that implements the A/E. Below is the code I used:

title
'Electrostatic Potential and Field Lines'
COORDINATES
cartesian2

variables
V {volts}
Q
! p
!D
!Tenergy

SELECT
!contourgrid=2
!overshoot
Ngrid =10
ERRLIM=1e-3
stages=1
quadratic {Quadratic FEM basis => default = order 2}

definitions
!stages=2

cm = 0.01
Lx=800*cm
Ly=1300*cm
eps0=8.854*10*(-12)
epr
eps=epr*eps0
Ex0 =1e-7 Dx0 = eps0*Ex0
Ex = -dx(V) Ey = -dy(V)
E= -grad(V) Em = magnitude(E)
Dex = eps*Ex Dey = eps*Ey
D= eps*E Dm = magnitude(D)
P = (eps - eps0)*E


Rho_f = DOT(-grad(V), P ) {surface free charge density}

!trunc=.05*errlim
!Tenergy = VOL_INTEGRAL ( V, '2' )

equations
V: div(eps*grad(V)) = 0 { Potential equation }
Q: div(grad(Q)/eps) = 0
!D: div(D) = 0 {same as div(eps*grad(V))} { adjoint equations }


constraints
!bintegral(V,"inner") = bintegral(1,"inner")
boundaries

region 1
eps0=8.854*10*(-12)
epr=1
eps=eps0*epr

start (-0.75,-1.3)
point value(V)=-12
value(V)=-12

line to (0.75, -1.3)
point value(V)=-12
value(V)=-12

line to (0.75,1.3)
point value(V)=-12
value(V)=-12

line to (-0.75,1.3)
point value(V)=-12
value(V)=-12

line to (-0.75, 1.3)
point value(V)=-12
value(V)=-12
line to close


region 2
eps0 =8.854*10*(-12)
epr=80
eps=eps0*epr


start (-0.25,0)

line to (0.25,0)
point value(V)=12 !natural(Q)= -normal(grad(v))
value(V) = 12 natural(Q)= tangential(grad(Q))

line to (0,0.5)
point value(V)=12 !natural(Q)= -normal(grad(V))
value(V)=12 natural(Q)= tangential(grad(Q))

line to (-0.25,0)
point value(V)=12 !natural(Q)= -normal(grad(V))
value(V)=12 natural(Q)= tangential(grad(Q))

line to (0,0)
point value(V)=12
value(V)=12 natural(Q)= tangential(grad(Q))
line to close

monitors
contour(V) as 'Potential'
contour(D) as 'Field'

plots
grid(x,y)
!contour(Sigma_b)
!surface(Sigma_b)
surface(Rho_f)
contour(Rho_f)
contour(V) as 'Potential'
surface(V) as 'Potential and Field Lines'
vector(-dx(V),-dy(V)) as 'Electric Field'
contour(E) zoom(0.3, 0.3, 0.65,0.5)
contour(V) zoom(0.3, 0.3, 0.65,0.5)
contour(Dm) zoom(0.3, 0.3, 0.65,0.5)
contour(D)
contour(Dex)
contour(Dey)
contour(Ex)
contour(Ey)
contour(Em)
contour(P) zoom(0.3, 0.3, 0.65,0.3)
contour(E) zoom(0.3, 0.4, 0.72, 0.4)
contour(P) zoom(0.3, 0.4, 0.72, 0.4)
elevation(V) from(0.707, 0.3) to (0.707,0.4)
vector(Dex, Dey)
vector(Ex, Ey)
contour(Dex) zoom(0.3, 0.3, 0.65,0.5)
contour(Dey) zoom(0.3, 0.3, 0.65, 0.5)
report(D) !does nothing
contour(Ex) zoom(0.3, 0.3, 0.65,0.5)
report(V)
contour(Ey) zoom(0.3, 0.3, 0.65,0.5)
report(V)
surface(Q)
surface(Dm)
surface(Ex)
surface(Ey)
surface(Dex)
surface(Dey)
end


I did an experiment using both figures in Deionized water in a cassarole dish and the end results were within +/- 1%. I was impressed!
I need help understanding div(grad(Q)/eps)=0. This is a simple question, I am willing to bet the answer is right under my nose.

My boss said it is an algorithm that makes it possible to plot the potential field lines. It is important that I know so that I may convey the concept to my students.
Top of pagePrevious messageNext messageBottom of page Link to this message

4maitland
New member
Username: 4maitland

Post Number: 2
Registered: 05-2010
Posted on Thursday, May 13, 2010 - 05:48 pm:   

Do I have run through Green's Theorem and integration by parts to arrive at a self adjoint representation? I am trying to present this software as a learning tool. To show the difference between the D field/ E field and polarization charge, etc. to help visualize the physics behind the math.
Any insight would be helpful.
Top of pagePrevious messageNext messageBottom of page Link to this message

4maitland
Junior Member
Username: 4maitland

Post Number: 3
Registered: 05-2010
Posted on Monday, May 17, 2010 - 11:43 am:   

I have a question and I hope somebody with greater experience and knowledge would give me a hint into what an "adjoint equation" is. If you go to the Backstrom Examples/Electricity/Steady State/Field Map, you will see the coding for the program.

My question is basically this: Div(eps*grad(V))=0 I'm okay with this. However, What I fail to understand, after raking the internet for info on the adjoint equation: div(grad(Q)/eps)=0 and not finding anything, and looking through my numerous texts on PDE's, I have only found one example of the adjoint equation. But you need a PhD in mathematics to understand it. Please explain this too me. I need to know, so that I may convey the info to others. Below is the one of many "working programs" under development:


title
'Electrostatic Potential and Field Lines'
COORDINATES
cartesian2

variables
V {volts}
Q
! p
!D
!Tenergy

SELECT
!contourgrid=2
!overshoot
Ngrid =5
ERRLIM=1e-3
stages=1
quadratic {Quadratic FEM basis => default = order 2}

definitions
!stages=2

cm = 0.01
Lx=800*cm
Ly=1300*cm
eps0=8.854*10*(-12)
epr
eps=epr*eps0
Ex0 =1e-7 Dx0 = eps0*Ex0
Ex = -dx(V) Ey = -dy(V)
E= -grad(V) Em = magnitude(E)
Dex = eps*Ex Dey = eps*Ey
D= eps*E Dm = magnitude(D)
P = (eps - eps0)*E


Rho_f = DOT(-grad(V), P ) {surface free charge density}

!trunc=.05*errlim
!Tenergy = VOL_INTEGRAL ( V, '2' )

equations
V: div(eps*grad(V)) = 0 { Potential equation }
Q: div(grad(Q)/eps) = 0
!D: div(D) = 0 {same as div(eps*grad(V))} { adjoint equations }


constraints
!bintegral(V,"inner") = bintegral(1,"inner")
boundaries

region 1
eps0=8.854*10*(-12)
epr=1
eps=eps0*epr

start (-0.75,-1.3)
point value(V)=-12
value(V)=-12

line to (0.75, -1.3)
point value(V)=-12
value(V)=-12

line to (0.75,1.3)
point value(V)=-12
value(V)=-12

line to (-0.75,1.3)
point value(V)=-12
value(V)=-12

line to (-0.75, 1.3)
point value(V)=-12
value(V)=-12
line to close


region 2
eps0 =8.854*10*(-12)
epr=80
eps=eps0*epr


start (-0.25,0)

line to (0.25,0)
point value(V)=12 !natural(Q)= -normal(grad(v))
value(V) = 12 natural(Q)= tangential(grad(Q))

line to (0,0.5)
point value(V)=12 !natural(Q)= -normal(grad(V))
value(V)=12 natural(Q)= tangential(grad(Q))

line to (-0.25,0)
point value(V)=12 !natural(Q)= -normal(grad(V))
value(V)=12 natural(Q)= tangential(grad(Q))

line to (0,0)
point value(V)=12
value(V)=12 natural(Q)= tangential(grad(Q))
line to close

monitors
contour(V) as 'Potential'
contour(D) as 'Field'

plots
grid(x,y)
!contour(Sigma_b)
!surface(Sigma_b)
surface(Rho_f)
contour(Rho_f)
contour(V) as 'Potential'
surface(V) as 'Potential and Field Lines'
vector(-dx(V),-dy(V)) as 'Electric Field'
contour(E) zoom(0.3, 0.3, 0.65,0.5)
contour(V) zoom(0.3, 0.3, 0.65,0.5)
contour(Dm) zoom(0.3, 0.3, 0.65,0.5)
contour(D)
contour(Dex)
contour(Dey)
contour(Ex)
contour(Ey)
contour(Em)
contour(P) zoom(0.3, 0.3, 0.65,0.3)
contour(E) zoom(0.3, 0.4, 0.72, 0.4)
contour(P) zoom(0.3, 0.4, 0.72, 0.4)
elevation(V) from(0.707, 0.3) to (0.707,0.4)
vector(Dex, Dey)
vector(Ex, Ey)
contour(Dex) zoom(0.3, 0.3, 0.65,0.5)
contour(Dey) zoom(0.3, 0.3, 0.65, 0.5)
report(D) !does nothing
contour(Ex) zoom(0.3, 0.3, 0.65,0.5)
report(V)
contour(Ey) zoom(0.3, 0.3, 0.65,0.5)
report(V)
surface(Q)
surface(Dm)
surface(Ex)
surface(Ey)
surface(Dex)
surface(Dey)
end

In a text I have it say's this about the adjoint equation: Lagrange's Identity say's; vLu-uMv where Mv is the (formal)adjoint of the differential operator "L". One last question pretaining to theory behind the adjoint of an opeartor. Does the idea behind the A/E basically stem from complex analysis if given a potential one must find the streamline, that is by finding the conjugate function? I also read someplace that the adjoint had it's beginnings in either aerodynamic's or fluid mechanics, is this accurate?

Maitland
Top of pagePrevious messageNext messageBottom of page Link to this message

4maitland
Member
Username: 4maitland

Post Number: 4
Registered: 05-2010
Posted on Monday, May 17, 2010 - 12:11 pm:   

In my previous post, I pasted a coded example of a working program. I also assembeled it as a lab experiment for undergraduates students taking intermediate E/M. I do not have my Bachelor's yet, but I am working on it. I was given the supreme privledge of instructing students into the "how too's" of FEM coding by borrowing sample codes from Backstroms Examples and modifying it. I used a casserole pan with Aluminum foil wrapped around the figure, in this case, the +12V on the triangle and as the -12V on the outer boundary or the "walls" surrounding the the triangular figure. When all said and done, the report I heard from the professor teaching the course told me that the lab worked out fine by the group of students who modified the coding into the proper dimensions for their extra credit project. I thank you for providing the means of solving complicated geometrical figures that don't have a closed form solutions and for having spent the time coding the subroutines that preform the numerical analysis for all users. Sure beats having to write reams and reams of code.

Maitland
Top of pagePrevious messageNext messageBottom of page Link to this message

4maitland
Member
Username: 4maitland

Post Number: 5
Registered: 05-2010
Posted on Monday, May 17, 2010 - 04:21 pm:   

Ok, I will wait. I been online all day, trying to figure out "why" the code I'm working on now fails to execute:
title
'Electrostatic Potential and Field Lines'
COORDINATES
cartesian2

VARIABLES
V {volts}
D

SELECT
!contourgrid=2
!overshoot
Ngrid =5
ERRLIM=1e-3
!stages=2
quadratic {Quadratic FEM basis => default = order 2}

INITIAL VALUES
V = 0
D = 0
DEFINITIONS

cm = 0.01
Lx=800*cm
Ly=1300*cm

eps0=8.854e-12
epr
eps=epr*eps0
{Equations for Electric Field}

E0= 1e-5 {Far Field}
Ex = -dx(V) Ey = -dy(V) {components of the gradient}
E = -E0*grad(V) {definition of the gradient}

D0 = eps*E0
Dx = dx(D) Dy = dy(D)
D_ = D0*grad(D) {D_ = eps*E0*grad(D)}
{components of the gradient (x,y)}
Em = magnitude(E)
Dm = magnitude(D_)
!P = (eps - eps0)*E
!Pm = magnitude(P)

!trunc=.05*errlim
!Tenergy = VOL_INTEGRAL ( V, '2' )

EQUATIONS
V: div(grad(V)) = 0 { Potential equation }
D: div(grad(D_)) = 0
{ adjoint equations }


CONSTRAINTS
!bintegral(V,"inner") = bintegral(1,"inner")
BOUNDARIES

REGION 1
eps0=8.854*e-12
epr=1
eps=eps0*epr

start (-0.75,-1.3)
point value(V)=-12
value(V)=-12

line to (0.75, -1.3)
point value(V)=-12
value(V)=-12

line to (0.75,1.3)
point value(V)=-12
value(V)=-12

line to (-0.75,1.3)
point value(V)=-12
value(V)=-12

line to (-0.75, 1.3)
point value(V)=-12
value(V)=-12
line to close


region 2
eps0 =8.854*e-12
epr=80
eps=eps0*epr


start (-0.25,0)

line to (0.25,0)
point value(V)=12 !natural(Q)= -normal(grad(v))
value(V) = 12 natural(V)= tangential(grad(D))

line to (0,0.5)
point value(V)=12 !natural(Q)= -normal(grad(V))
value(V)=12 natural(D)= tangential(grad(D))

line to (-0.25,0)
point value(V)=12 !natural(Q)= -normal(grad(V))
value(V)=12 natural(D)= tangential(grad(D))

line to (0,0)
point value(V)=12
value(V)=12 natural(D)= tangential(grad(D))
line to close

MONITORS
contour(V) as 'Potential'
contour(D) as 'Field'

PLOTS
grid(x,y)
contour(V) as 'Potential'
surface(V) as 'Potential and Field Lines'
vector(-dx(V),-dy(V)) as 'Electric Field'
vector(dx(D), dy(D))
contour(E) zoom(0.3, 0.3, 0.65,0.5)
contour(V) zoom(0.3, 0.3, 0.65,0.5)
contour(Dm) zoom(0.3, 0.3, 0.65,0.5)
contour(D_)
!contour(Dex)
!contour(Dey)
contour(Ex)
contour(Ey)
contour(Em)
!contour(P) zoom(0.3, 0.3, 0.65,0.3)
contour(E) zoom(0.3, 0.4, 0.72, 0.4)
!contour(P) zoom(0.3, 0.4, 0.72, 0.4)
elevation(V) from(0.707, 0.3) to (0.707,0.4)
!vector(Dex, Dey)
vector(Ex, Ey) as 'V/cm'
surface(Ex)
surface(Ey)
!surface(Dex)
!surface(Dey)
end

Maitland
Top of pagePrevious messageNext messageBottom of page Link to this message

mgnelson
Moderator
Username: mgnelson

Post Number: 190
Registered: 07-2007
Posted on Monday, May 17, 2010 - 06:00 pm:   

There are a few errors in this script :

1) You are redefining DX. DX is a reserved word. You will have to use some other name for your definition (note that FlexPDE is NOT case sensitive - DX is the same as dx).
i.e. DxD = dx(D)

2) Your governing equation for D is div(grad(D_)). Which expands to div(grad(grad(D))). This is an invalid construct for two reasons. First, grad internally creates a tensor, from which the div creates a vector. So, D would have to be a vector variable. Second, it creates a third order equation which is not supported in FlexPDE. I assume you wanted div(D_) as the governing equation. [Note: Maxwell's equation is div(eps*grad(V))=0 you cannot remove eps unless it is a constant.]

3) In your regional redefinition of EPS0, you have stated 8.4*e-12 instead of 8.4e-12. Since you have a vector quantity named E, evaluation of expressions containing EPS0 are confused, since it is now a vector quantity also. Note that you defined EPS0 correctly in the DEFINITIONS section and do not need to redefine it. Only your EPR value is changing in each region. So you don't need to redefine EPS0 anyway. Just remove the redefinition.

4) You have requested a CONTOUR plot of vector quantities E and D_. Either use a VECTOR plot or plot a contour of a component of the vector.


Here I have attached a copy of your script with these modifications.

application/octet-stream
epotential.pde (2.7 k)
Top of pagePrevious messageNext messageBottom of page Link to this message

4maitland
Member
Username: 4maitland

Post Number: 6
Registered: 05-2010
Posted on Tuesday, May 18, 2010 - 08:25 am:   

How complicated can some scripts be? I had heard that a local compny in my area which specializes in mass transport via rail car, used your program and it was said by a chap that worked there as a Q/C programmer, that the script ran for days! Is this possible with the professional version?

Jon
Top of pagePrevious messageNext messageBottom of page Link to this message

rgnelson
Moderator
Username: rgnelson

Post Number: 1364
Registered: 06-2003
Posted on Tuesday, May 18, 2010 - 12:48 pm:   

It is possible to construct problems that run a very long time. It depends on the characteristics of the model.
But very long run time can also be a symptom of an ill-posed equation system. If the system does not have a unique solution, or if the PDE and the boundary conditions are in conflict, FlexPDE may struggle badly searching for a non-existent solution.

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