New answers tagged

2

This seems to work? Clear[x, y, z, u,p,U]; p = Parallelepiped[{0, 0, 0}, {{1, 0, 0}, {1, 1, 0}, {0, 1, 1}}]; U = NDSolveValue[{Laplacian[u[x, y, z], {x, y, z}] == 0, DirichletCondition[u[x, y, z] == x^4 + y^2 + z, True]}, u, {x, y, z} \[Element] p]; Then U[x, y, z] // Evaluate, {x, y, z} \[Element] p, Contours -> 5, MeshFunctions -> (Norm[{...


5

One can define an "infinite" domain-based solely on $t_{max}$ for a purely diffusive problem. The key disadvantage of using this approach versus anisotropic meshing is that the mesh will change as a function of $t_{max}$ and $\mathcal{D}$. The analytical solution for one-dimensional diffusion is: $$\frac{{{C_A}\left( {t,x} \right)}}{{{C_{A0}}}} = ...


5

Anisotropic Meshing The following is a feature request for anisotropic meshing. A proper mesh is as or more important than just having the proper equations to obtain accurate simulation results. The problem arises when one needs to capture either very close or very far away from some feature in the main model. Naïvely meshing the model with the uniform mesh ...


7

"Infinite domains" with anisotropic meshing I will demonstrate an approach that extends the domain by a factor of a thousand with a small increase in computational cost through anisotropic meshing. I will verify the approach using heat transfer in an infinite rod where the analytical solution is known. Helper functions I will use some of the ...


6

I think you betw data is a bit messed up. I show you how to work around that. We ignore betw and in stead ad a line connecting the str and mcr boundaries = {mcr, betz, st, air}; Needs["NDSolve`FEM`"] bms = Join[ ToBoundaryMesh /@ boundaries, {ToBoundaryMesh[ "Coordinates" -> {{0.447`, 0.868`}, {0.483`, 0.868`}}, &...


3

Here is something to get you started. dA = 1; dB = 1; ka = 1; kc = 1; cAbulk = 1; eqn1 = D[cA[x, t], t] - Inactive[Div][dA Inactive[Grad][cA[x, t], {x}], {x}]; eqn2 = D[cB[x, t], t] - Inactive[Div][dB Inactive[Grad][cB[x, t], {x}], {x}]; large = 10; {ncA, ncB} = NDSolveValue[{eqn1 == NeumannValue[kc cA[x, t] - ka cB[x, t], x == 0], cA[...


5

We can solve this problem using FEM and implicit Euler in a Case 1, 2, 4 from the report Option Pricing under a Heston Volatility model using ADI schemes by Jieshun Luo, Qi Wang, Nestor Carbayo. Case 3 looks very tricky, so I can't handle it with my code. First we map region $0\le s\le 800, 0\le v\le 5$ to unit square by substitution $x=s/L_x,y=v/L_y$ with $...


5

Also you can it try this way with version 12.2 sol = NDSolveValue[{D[u[t, x], t] + DiffusionPDETerm[{u[t, x], {x}}] == 0, u[0, x] == (Sin[Pi*x])^100}, u, {x, 0, 1}, {t, 0, 2}] Plot3D[sol[t, x], {x, 0, 1}, {t, 0, 0.1}, PlotRange -> All] To complete this, the following addition: heatSol = NDSolveValue[{HeatTransferPDEComponent[{u[t, x], t, {x}}, <...


3

"startup aid" U = NDSolveValue[{Derivative[0, 1][u][x, t] ==Derivative[2, 0][u][x, t], u[x, 0] == Sin[Pi x]^100 }, u, {t, 0, 1}, {x, 0, 1} , Method -> {"MethodOfLines", "TemporalVariable" -> t,"SpatialDiscretization" -> "FiniteElement" }] NDSolveValue evaluates the solution U[x,t] as an ...


3

I'm posting this as an answer only because it is good enough for my requirements at the moment. I have taken the code provided by Alex Trounev in the first answer and modified it to decay the two dirichlet conditions in time. As the top and bottom velocities decay, the flow starts resembling 2D channel flow (as the top and bottom effectively approach the no ...


5

For 2D time dependent incompressible flow we can use linear FEM, as it discussed on Solver for unsteady flow with the use of the Navier-Stokes and Mathematica FEM. This solver has been tested and compared with other different approaches. The linear FEM solver shows also nice solution for the problem for turbulent like initial data. We use as initial data the ...


2

Since currently ElementMeshInterpolation does not support PeriodicInterpolation and Interpolation only support PeriodicInterpolation on rectangular grid. Apart from user21's workaround, I developed a workaround for arbitrary parallel or parallelipiped grid periodic interpolation. The idea is naive, just to pull back points outside region by base vectors. ...


10

You can not really. The fact that Interpolation can do this hinges on the data being structured. In other works what I am going to show next is not easily generally possible for meshes that represent a non rectangullar domain; which is the common case for FEM meshes. You can hack it by using the ExtrapolationHandler option. Needs["NDSolve`FEM`"]...


3

Like shown in the comments by Henrik, you'd need to refine the mesh H1[ρ_, m_, l_] := R''[ρ] + 1/ρ*R'[ρ] - (m + 1)/l^2*R[ρ] - m^2/ρ^2*R[ρ] - ρ^2/(4*l^4)*R[ρ]; H1test = H1[ρ, 1, 1]; {PapEvals, PapEvecs} = NDEigensystem[{-H1test, DirichletCondition[R[ρ] == 0, True]}, R[ρ], {ρ, 0, 50}, 5, Method -> {"PDEDiscretization" -> {"...


7

As a workaround you can use the finite element mesh generator: Needs["NDSolve`FEM`"] coordinateList = Tuples[{Range[3], Range[3], Range[3]}]; MeshRegion[ToElementMesh[coordinateList], PlotTheme -> "Lines"]


Top 50 recent answers are included