How do I use low level FEM?
$begingroup$
How do I simulate the following partial differential equation using Low level FEM in Mathematica?
D[u[x,y], x] - D[u[x,y], y] = x Sin[x y] - y Sin[x y]
The answer is Cos[x y]
added)
The region is [-1,1] for x and [-1,1] for y.
The boundary condition is u[-1,y]=Cos[-y]
finite-element-method
$endgroup$
|
show 5 more comments
$begingroup$
How do I simulate the following partial differential equation using Low level FEM in Mathematica?
D[u[x,y], x] - D[u[x,y], y] = x Sin[x y] - y Sin[x y]
The answer is Cos[x y]
added)
The region is [-1,1] for x and [-1,1] for y.
The boundary condition is u[-1,y]=Cos[-y]
finite-element-method
$endgroup$
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
Jan 16 at 12:38
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
Jan 16 at 12:41
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
Jan 16 at 12:43
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
Jan 16 at 12:45
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
Jan 16 at 12:50
|
show 5 more comments
$begingroup$
How do I simulate the following partial differential equation using Low level FEM in Mathematica?
D[u[x,y], x] - D[u[x,y], y] = x Sin[x y] - y Sin[x y]
The answer is Cos[x y]
added)
The region is [-1,1] for x and [-1,1] for y.
The boundary condition is u[-1,y]=Cos[-y]
finite-element-method
$endgroup$
How do I simulate the following partial differential equation using Low level FEM in Mathematica?
D[u[x,y], x] - D[u[x,y], y] = x Sin[x y] - y Sin[x y]
The answer is Cos[x y]
added)
The region is [-1,1] for x and [-1,1] for y.
The boundary condition is u[-1,y]=Cos[-y]
finite-element-method
finite-element-method
edited Jan 23 at 7:35
Xminer
asked Jan 16 at 12:18
XminerXminer
15418
15418
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
Jan 16 at 12:38
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
Jan 16 at 12:41
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
Jan 16 at 12:43
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
Jan 16 at 12:45
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
Jan 16 at 12:50
|
show 5 more comments
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
Jan 16 at 12:38
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
Jan 16 at 12:41
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
Jan 16 at 12:43
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
Jan 16 at 12:45
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
Jan 16 at 12:50
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
Jan 16 at 12:38
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
Jan 16 at 12:38
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
Jan 16 at 12:41
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
Jan 16 at 12:41
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
Jan 16 at 12:43
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
Jan 16 at 12:43
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
Jan 16 at 12:45
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
Jan 16 at 12:45
1
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
Jan 16 at 12:50
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
Jan 16 at 12:50
|
show 5 more comments
1 Answer
1
active
oldest
votes
$begingroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Also, there is a tutorial about Finite Element Programming that has much more information on this topic.
Hope this helps a bit.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189595%2fhow-do-i-use-low-level-fem%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Also, there is a tutorial about Finite Element Programming that has much more information on this topic.
Hope this helps a bit.
$endgroup$
add a comment |
$begingroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Also, there is a tutorial about Finite Element Programming that has much more information on this topic.
Hope this helps a bit.
$endgroup$
add a comment |
$begingroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Also, there is a tutorial about Finite Element Programming that has much more information on this topic.
Hope this helps a bit.
$endgroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Also, there is a tutorial about Finite Element Programming that has much more information on this topic.
Hope this helps a bit.
edited Jan 22 at 7:49
answered Jan 16 at 13:36


user21user21
19.7k45184
19.7k45184
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189595%2fhow-do-i-use-low-level-fem%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
Jan 16 at 12:38
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
Jan 16 at 12:41
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
Jan 16 at 12:43
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
Jan 16 at 12:45
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
Jan 16 at 12:50