The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Tag Info

New answers tagged finite-element-method

1

This code reproduces the analytical solution with high accuracy. << NDSolveFEM H = 1; L = 2; \[CapitalOmega]1 = Rectangle[{0, 0}, {L, H}]; \[CapitalOmega]2 = Rectangle[{0, -H}, {L, 0}]; RegionPlot[RegionUnion[\[CapitalOmega]1, \[CapitalOmega]2], AspectRatio -> Automatic] mesh1 = ToElementMesh[\[CapitalOmega]1, "MaxCellMeasure" -> 0....

10

Using my 40+ years of experience modeling unsteady supersonic flows I can offer a working FEM code for isentropic viscous flows. Here you can add the equation for temperature with $\chi$ function, but this almost does not affect the solution. A flow with the inlet/outlet pressure ratio $p_{in}/p_{out}=25$ is considered here. Mach number at nozzle exit \$M=3....

4

I am not sure I understand your question 100%, do you mean something like this: r = RegionDifference[ RegionDifference[Cuboid[{-1, -1, -1}, {1, 1, 1}], Cylinder[{{0, 0, -1/4}, {0, 0, -1/2}}, 1/2]], Cylinder[{{0, 0, 1/4}, {0, 0, 1/2}}, 1/2]]; Needs["NDSolveFEM"] (mesh = ToElementMesh[r, "RegionHoles" -> {{0, 0, 3/8}, {0, 0, -3/8}}])["...

2

Use asymptotics at initial value r == 0 to define u'' for ode2: ode = r*u''[r] + 2*u'[r] + r*(Pi/64)*Exp[-128*r^2]*(1 - u[r]^5) == 0; ode2 = u''[r] == Piecewise[{ {u''[r] /. First@Solve[ode, u''[r]], r != 0} }, 2 Coefficient[ AsymptoticDSolveValue[{1/64 E^(-128 r^2) \[Pi] r (1 - u[r]^5) + 2 u'[r] + r u''[r] == 0, u' == 0, u...

7

I cannot take credit for the following code, but it allows one to join several boundary meshes together. Needs["NDSolveFEM"] (* Code to join multiple boundary meshes *) ClearAll[validInputQ] validInputQ[bm1_, bm2_] := BoundaryElementMeshQ[bm1] && BoundaryElementMeshQ[ bm2] && (bm1["EmbeddingDimension"] === bm2["...

3

The issue here is that currently NDSolve with the finite element method can not handle non-constant coefficients for time derivatives. In order to work around that I reformulated your equations by dividing the equations by that non-constant coefficient. You need to check that I did not make a mistake here. I started by simplifying your D calls in the ...

3

This is a simple typo. Use: NDEigensystem[eqns, {y1, y2}, {x, -5, 5}, {θ, 0, 2 Pi}, 4] (* {{-0.0329282, 0.526089, 0.940386, 1.4994},... *) not the {{x, -5, 5}, {θ, 0, 2 Pi}} you have.

2

Homogeneous boundary conditions are used here. f1[x_, θ_] := x^2 + Cos[θ] f2[x_, θ_] := x^2 + x + Cos[θ] eqns = {-D[D[y1[x, θ], x], x] - D[D[y1[x, θ], θ], θ] + f1[x, θ]*y1[x, θ] + x*y2[x, θ], -D[D[y2[x, θ], x], x] - D[D[y2[x, θ], θ], θ] + f2[x, θ]*y2[x, θ] + x*y1[x, θ]}; {vals, funs} = NDEigensystem[{eqns, ...

4

First of all, PDE == nv1 + nv2 + nv3 + nv4 is obviously wrong, because there already exists a == in your PDE. This is easy to fix of course. What's confusing is the Power::infy warning. I'm not sure why this pops up, maybe NDSolve fails to notice FiniteElement should be chosen in this case, while it should be able to. Anyway, specifying the method ...

2

Your equation is not in the correct form for FEM. Homogeneous Neumann conditions are applied automatically. Needs["NDSolveFEM"] Bi = 0.5; xf = 5; reg = Rectangle[{0, 0}, {xf, 1}]; mesh = ToElementMesh[reg, MaxCellMeasure -> 0.0001]; PDE = D[M[t, x, y], t] - 1/(x^2 + y^2)*D[(x^2 + 1)*D[M[t, x, y], x], x] - 1/(x^2 + y^2)*D[(-y^2 + 1)*D[M[t, x, y], y], ...

4

If you use ToElementMesh versus DiscretizeRegion and look at the "Wireframe", then you will see that your mesh looks pretty ugly. mesh["Wireframe"] You can make a prettier mesh by starting with a geometry that has more cube-like aspect ratio and then scale the z-coordinate and remesh as shown below: Needs["NDSolveFEM"] (* Stretch Disc Region for better ...

1

I think something is not quite right with way you process the equations. If you use this you get what you expect: b = 1; c = 1; h[x_] = -b x + c Cos[2 x]/2; Lh[l_, x_] := D[l[x], x, x] - (1/4) (D[h[x], x])^2 l[x] {vals, funs} = NDEigensystem[{-Lh[l, x], l == l[Pi]}, l, {x, 0, Pi}, 6, Method -> {"PDEDiscretization" -> {"FiniteElement", {"...

2

For NDEigensystem[], only homogeneous boundary conditions can be set. In this case, we have b = 1; c = 1; h[x_] := -b x + c Cos[2 x]/2 eq = -(D[l[z], z, z] - (1/4) (D[h[z], z])^2 l[z]); {vals, funs} = NDEigensystem[{eq, DirichletCondition[l[z] == 0, z == 0 || z == Pi]}, l[z], {z, 0, Pi}, 5] Table[Plot[{eq /. l[z] -> funs[[i]], vals[[i]] funs[[i]]...

1

If I understand you right: RRMAX[\[Theta]_] := 60 (1 - 0.1 Cos[\[Theta]]) n[r] = Exp[-r^2] sol = NDSolveValue[{1/r^2 D[r^2*D[f[r, \[Theta]], r], r] == n[r], DirichletCondition[f[r, \[Theta]] == 0, r == RRMAX]}, f, {r, 0, RRMAX}, {\[Theta], 0, 2 \[Pi]}] NDSolveValue::femcscd: The PDE is convection dominated and the result may not be stable. ...

Top 50 recent answers are included