How to make contour plots for 2D Finite Element problems

In summary, the conversation discusses the use of Finite Element Method to solve a 2D boundary value problem in electromagnetics. The speaker has written a program in MATLAB and needs help with obtaining a contour plot for the solution in the entire solution domain. They have tried using interpolation equations, but have not been successful and are seeking guidance on how to proceed.
  • #1
maverick280857
1,789
4
To the moderator: Please shift this to the appropriate forum if this isn't the place for it. EDIT -- It seems this (https://www.physicsforums.com/forumdisplay.php?f=189) is the right place for it? Sorry I overlooked this forum.

-----
Hi everyone,

I am solving some 2D boundary value problems in electromagnetics, using the Finite Element Method to familiarize myself with the method before I can apply it to my senior project. I have written a program in MATLAB which to solve the Laplace Equation using the FEM, on a rectangular solution domain defined by the coordinates (0,0), (1,0), (1,1), (0,1) [a square in this case]. The boundary conditions are

V(x = 0) = V(x = 1) = 0
V(y = 0) = 0
V(y = 1) = V_0 (some fixed constant value)

I have been able to write a program that generates a mesh for this region (please refer to attached diagram), and computes the value of the potential at every non-boundary node of the region (points of the triangular elements). Now, I need to use the element shape functions to interpolate the potential at points interior to an element using

(a) the values of the potential at its 3 nodes
(b) Lagrange polynomials (element shape functions)

I want to obtain a contour plot for the solution in the entire solution domain. What is the best and easiest way to go about this?

I thought of specifying several points within each triangular region and use the interpolation equation to calculate the values of the potential at those points. Then I would have a set of points (x, y, V(x,y)) which I could use to make a surface plot. I got a very poor plot when I tried this, so I am guessing there is something wrong in the way I've plotted this.
 

Attachments

  • mesh.jpg
    mesh.jpg
    23.1 KB · Views: 546
Physics news on Phys.org
  • #2
I would really appreciate it if someone could help me with this and provide some guidance on how to proceed.Thanks in advance!
 
  • #3
Any suggestions on how to proceed would be greatly appreciated!

Hello,

Thank you for your question. Contour plots are a useful tool for visualizing 2D Finite Element problems. They provide a clear representation of the solution over the entire solution domain, making it easier to identify patterns and trends in the data.

To make a contour plot for a 2D Finite Element problem, you will need to follow these steps:

1. Generate a mesh for the solution domain: This can be done using the coordinates of the solution domain and dividing it into smaller triangular elements.

2. Solve the problem using the Finite Element Method: Use the mesh generated in the previous step to solve the problem and obtain the values of the solution at each node of the mesh.

3. Interpolate the solution at points within each element: Use the element shape functions and the values of the solution at the nodes to interpolate the solution at points within each element.

4. Create a grid of points over the solution domain: Define a grid of points over the solution domain where you want to plot the contour plot. These points should be evenly spaced and cover the entire solution domain.

5. Use the interpolated values to plot the contour lines: Use the interpolated values of the solution at the grid points to plot the contour lines. You can use a function like contourf in MATLAB to plot the contour lines.

6. Add labels and legends to the plot: Finally, add appropriate labels and legends to your plot to make it easier to understand.

I hope this helps. Good luck with your senior project!
 

1. How do I create a contour plot for a 2D Finite Element problem?

To create a contour plot for a 2D Finite Element problem, you will need to first discretize your domain into smaller elements and then solve the problem using a Finite Element method. Once the solution is obtained, you can plot the results on a 2D grid using a contour plot function.

2. What software can I use to make contour plots for 2D Finite Element problems?

There are many software options available for creating contour plots for 2D Finite Element problems, such as MATLAB, ANSYS, and COMSOL. It is important to choose a software that is compatible with the Finite Element method and has the necessary tools for creating contour plots.

3. Can I customize the contour plot for my 2D Finite Element problem?

Yes, most software programs allow for customization of contour plots, such as choosing the color scheme, number of contour lines, and adding labels and annotations. You can also adjust the resolution and size of the plot to suit your needs.

4. How do I interpret a contour plot for a 2D Finite Element problem?

A contour plot is a graphical representation of the solution to a 2D Finite Element problem. The contour lines represent regions of equal values, with the values increasing or decreasing as you move from one contour line to the next. The colors or shading can also be used to represent the values in the plot.

5. Are there any limitations to using contour plots for 2D Finite Element problems?

Contour plots are a useful tool for visualizing and interpreting results from 2D Finite Element problems, but they do have some limitations. They may not accurately represent the true behavior of the problem in areas where the solution changes rapidly, and they may not be suitable for problems with complex geometries or boundary conditions.

Similar threads

Replies
6
Views
2K
Replies
3
Views
808
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Mechanical Engineering
Replies
1
Views
2K
  • Quantum Physics
Replies
12
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
723
  • Programming and Computer Science
Replies
2
Views
1K
  • Atomic and Condensed Matter
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
973
  • Advanced Physics Homework Help
Replies
3
Views
1K
Back
Top