Wolfram FEM | Things to Try

Make edits and run any piece of code by clicking inside the code and pressing
+
.
Finite Element Method. For beginners to experts, Wolfram FEM captures the behavior of your design by providing multiphysics partial differential equation models, solvers and seamless post-processing functions, fully integrated with advanced geometry and visualization capabilities.

Fluid Dynamics

Set up a Navier–Stokes equation with a symbolic Reynolds number ℛℯ, fluid velocities
u
and
v
and pressure
p
:
Run
In[]:=
vars={{u[x,y],v[x,y],p[x,y]},{x,y}};​​pars=<|"ReynoldsNumber"->ℛℯ|>;
Create a geometry with a hole in the middle:
Run
In[]:=
Ω=RegionDifference[Rectangle[],Disk[{1/2,1/2},1/5]];
Define the PDE and boundary conditions:
Run
In[]:=
pde=FluidFlowPDEComponent[vars,pars]=={0,0,0};​​bcs={DirichletCondition[{u[x,y]1,v[x,y]0},y1],DirichletCondition[{u[x,y]0,v[x,y]0},y<1],DirichletCondition[p[x,y]0,x0&&y0]};
Create a Navier–Stokes solver depending on the parameter ℛℯ:
Run
In[]:=
navierStokesSolver=ParametricNDSolveValue[{pde,bcs},{u[x,y],v[x,y],p[x,y]},{x,y}∈Ω,ℛℯ,Method{"FiniteElement","InterpolationOrder"{u2,v2,p1}}];
Solve the Navier–Stokes equation for a Reynolds number ℛℯ=100:
Run
In[]:=
{xVelocity,yVelocity,pressure}=navierStokesSolver[100];
Make a stream plot of the fluid velocities:
Run
In[]:=
StreamPlot[{xVelocity,yVelocity},{x,y}∈Ω]

More to Try

◼
  • Use a Reynolds number, ℛℯ, equal to 1000 (this method should converge well until about 5000).
  • ◼
  • Change the geometry by moving the hole in the solution region.
  • ◼
  • Add a second parameter to change the flow speed at the top boundary condition.
  • Next Steps

    Explore the fluid dynamics application models and monographs or the FluidFlowPDEComponent reference page.

    Coupled Heat Transfer and Mass Transport

    Multiphysics models combine different aspects of the same physical system into one coupled model. For example, a temperature- and concentration-dependent chemical reaction:
    heattransfermodel
    ︷
    ∂T(t,x)
    ∂t
    +∇·(-k∇T(t,x))-Q
    =
    0
    masstransportmodel
    ︷
    ∂c(t,x)
    ∂t
    +∇·(-d∇c(t,x))-R
    =
    0
    Solve a coupled heat and mass transport model on the interval
    x∈[0,1]
    .
    Set up the heat transfer mass transport model variables temperature
    T
    , concentration
    c
    and time
    t
    :
    Run
    In[]:=
    hvars={T[t,x],t,{x}};​​mvars={c[t,x],t,{x}};
    Specify model parameters with thermal conductivity
    k
    , mass diffusivity
    d
    , heat source
    Q
    and mass source
    R
    that couples temperature and concentration:
    Run
    In[]:=
    pars=<|"ThermalConductivity"0.01,"DiffusionCoefficient"0.01,"HeatSource"0.2*R,"MassSource"R,R->-10^-3*T[t,x]*c[t,x]|>;
    Set up the coupled PDEs and initial conditions:
    Run
    In[]:=
    pdes={HeatTransferPDEComponent[hvars,pars]0,MassTransportPDEComponent[mvars,pars]0};​​ics={T[0,x]200+800x,c[0,x]800};
    Solve the model:
    Run
    In[]:=
    {Tfun,cfun}=NDSolveValue[{pdes,ics},{T,c},{t,0,10},{x}∈Line[{{0},{1}}]];
    Explore how the solution evolves in time:
    Run
    In[]:=
    ManipulatePlot{cfun[t,x],Tfun[t,x]},{x}∈Line[{{0},{1}}],
    ,{{t,1.3},0,10},
    

    More to Try

    ◼
  • Modify the initial conditions or the parameter R.
  • ◼
  • Set up, solve and visualize the problem in two spatial dimensions.
  • Next Steps

    Explore the heat transfer application models and monographs,
    the mass transport application models and monographs or the HeatTransferPDEComponent or MassTransportPDEComponent reference pages.

    Quantum Mechanics

    Set up a 1D time-dependent problem with a harmonic potential:
    Run
    In[]:=
    vars={Ψ[t,x],t,{x}};​​pars=<|"ReducedPlanckConstant"->1,"SchrodingerPotential"->
    2
    x
    2
    |>;
    Define the PDE, with a coherent state as initial condition:
    Run
    In[]:=
    pde=SchrodingerPDEComponent[vars,pars]==0;​​ic=Ψ[0,x]==
    1
    4
    1
    π
    -
    2
    (x-1)
    2
    
    ;
    Solve the resulting model:
    Run
    In[]:=
    solution=NDSolveValue[{pde,ic},Ψ,{t,0,20},{x,-4,4}]
    Visualize the coherent state oscillating between the classical turning points:
    Run
    In[]:=
    AnimatePlot
    2
    Norm[solution[t,x]]
    ,
    2
    x
    2
    ,{x,-4,4},
    ,{t,0,20},
    

    More to Try

    ◼
  • Change the potential and initial state to study a scattering problem.
  • ◼
  • Compute eigenfunctions of a time-independent Hamiltonian.
  • ◼
  • Model a quantum system in two or three spatial dimensions.
  • Next Steps

    Explore the physics application models and monographs or the SchrodingerPDEComponent reference page.