Main Content

Migration from Domain-Specific to Unified Workflow

The unified finite element model workflow defines the type of a problem and all of its parameters as the properties of an femodel object. This object enables you to specify physical parameters for structural, thermal, and electromagnetic types of analyses. The solver in the unified workflow uses only the parameters (properties) appropriate for the current analysis type while ignoring all other properties. If you switch the analysis type by setting the AnalysisType property of the model, the solver uses the appropriate set of properties corresponding to the new analysis type.

This table shows common steps for solving structural, thermal, and electromagnetic problems and the corresponding syntaxes in the domain-specific workflow and the unified workflow.

TaskDomain-Specific WorkflowUnified Workflow

Create an object to store all parameters of a problem.

createpde

femodel

Set the PlanarType property of femodel to "axisymmetric" for axisymmetric problems. The x-axis represents to the radial component, and the y-axis represents the axial component.

Specify a geometry.

importGeometry

fegeometry or specify the geometry when creating a model: model = femodel(Geometry=...)

Generate a mesh.

generateMesh(model)

Mesh is stored as model.Mesh.

model = generateMesh(model)

Assign the result to the model to update the mesh stored in the Geometry property of the model.

Mesh is stored as model.Geometry.Mesh.

Specify properties of materials: Young's modulus, Poisson's ratio, mass density, hysteretic damping, coefficient of thermal expansion, thermal conductivity, specific heat, relative permittivity, relative permeability, and electric conductivity.

structuralProperties, thermalProperties, electromagneticProperties

materialProperties

Specify boundary conditions: displacement, constraints, temperature, voltage, magnetic potential, and electric and magnetic fields.

structuralBC, thermalBC, electromagneticBC

Supported structural constraints are "free", "fixed", "roller", "symmetric", and "multipoint".

faceBC, edgeBC

Supported structural constraints are empty (equivalent to "free" in the domain-specific workflow) and "fixed".

For nonconstant boundary conditions, use the approach described in these topics:

Specify structural boundary loads: surface traction, pressure, translational stiffness, and concentrated force.

structuralBoundaryLoad

faceLoad, edgeLoad, vertexLoad

For nonconstant loads, use the approach described in these topics:

Specify acceleration due to gravity, angular velocity, and thermal load.

structuralBodyLoad

cellLoad, faceLoad

Specify internal heat source.

internalHeatSource

Heat name-value argument of cellLoad and faceLoad

Specify heat flux through a boundary, ambient temperature, convection coefficient, and emissivity.

thermalBC

faceLoad, edgeLoad

Specify current density, charge density, and magnetization.

electromagneticSource

cellLoad, faceLoad

Specify initial displacement, velocity, and temperature.

structuralIC, thermalIC

Displacement, velocity, and temperature do not have default values.

cellIC, faceIC, edgeIC, vertexIC

By default, both initial displacement and velocity are zero. Temperature does not have a default value. You must specify initial temperature for both time-dependent and nonlinear problems, even if a nonlinear problem does not depend on time.

Examples of Code Conversion

These examples show the line-by-line comparison between the code that uses a StructuralModel object, a ThermalModel object, or an ElectromagneticModel object and the code that uses an femodel object.

Structural Analysis

Convert the code for analyzing a bracket under an applied load from the domain-specific workflow, which uses a StructuralModel object, to the unified workflow, which uses an femodel object.

Domain-Specific WorkflowUnified Workflow
%% Deflection Analysis of Bracket

% Create a model and include the bracket geometry.
model = createpde("structural","static-solid");
importGeometry(model,"BracketWithHole.stl");

% Specify Young's modulus and Poisson's ratio of the material.
structuralProperties(model,YoungsModulus=200e9, ...
                           PoissonsRatio=0.3);

% Specify that face 4 is a fixed boundary.
structuralBC(model,Face=4,Constraint="fixed");

% Apply a distributed load in the negative z-direction to face 8.
structuralBoundaryLoad(model,Face=8,SurfaceTraction=[0;0;-1e4]);

% Generate a mesh.
generateMesh(model);

% Solve the problem.
result = solve(model)
%% Deflection Analysis of Bracket

% Create a model and include the bracket geometry.
model = femodel(AnalysisType="structuralStatic", ...
                Geometry="BracketWithHole.stl");

% Specify Young's modulus and Poisson's ratio of the material.
model.MaterialProperties = ...
        materialProperties(YoungsModulus=200e9,PoissonsRatio=0.3);

% Specify that face 4 is a fixed boundary.
model.FaceBC(4) = faceBC(Constraint="fixed");

% Apply a distributed load in the negative z-direction to face 8.
model.FaceLoad(8) = faceLoad(SurfaceTraction=[0;0;-1e4]);

% Generate a mesh and assign it to the model.
model = generateMesh(model);

% Solve the problem.
result = solve(model)

Structural Analysis with Rectangular Pressure Pulse

Convert the code for analyzing a bracket under a short pressure pulse from the domain-specific workflow, which uses a StructuralModel object, to the unified workflow, which uses an femodel object.

Domain-Specific WorkflowUnified Workflow

When using this workflow, model a rectangular pressure pulse using the StartTime and EndTime name-value arguments of structuralBoundaryLoad.

%% Rectangular Pressure Pulse on Boundary

% Create a model and include the bracket geometry.
model = createpde("structural","transient-solid");
importGeometry(model,"BracketWithHole.stl");

% Specify Young's modulus, Poisson's ratio, and mass density.
structuralProperties(model,YoungsModulus=200e9, ...
                           PoissonsRatio=0.3, ...
                           MassDensity=7800);

% Specify that face 4 is a fixed boundary.
structuralBC(model,Face=4,Constraint="fixed");

% Set the initial displacement to 0.
structuralIC(model,Displacement=[0;0;0]);

% Apply a rectangular pressure pulse on face 7 in the direction normal to the face.
structuralBoundaryLoad(model,Face=7,Pressure=10^5, ...
                             EndTime=0.002);

% Generate a mesh.
generateMesh(model,Hmax=0.05);

% Solve the problem.
result = solve(model,linspace(0,0.01,100))

When using this workflow, model a rectangular pressure pulse using a helper function.

%% Rectangular Pressure Pulse on Boundary

% Create a model and include the bracket geometry.
model = femodel(AnalysisType="structuralTransient", ...
                Geometry="BracketWithHole.stl");

% Specify Young's modulus, Poisson's ratio, and mass density.
model.MaterialProperties = ...
        materialProperties(YoungsModulus=200e9, ...
                           PoissonsRatio=0.3,MassDensity=7800);

% Specify that face 4 is a fixed boundary.
model.FaceBC(4) = faceBC(Constraint="fixed");

% By default, both the initial displacement and velocity are set to 0. 

% Apply a rectangular pressure pulse on face 7 in the direction normal to the face.
pressurePulse = @(location,state) ...
         rectangularLoad(10^5,location,state,[0.0 0.002]);
model.FaceLoad(7) = faceLoad(Pressure=pressurePulse);

% Generate a mesh and assign it to the model.
model = generateMesh(model,Hmax=0.05);

% Solve the problem.
result = solve(model,linspace(0,0.01,100))

The helper function for specifying a rectangular pressure pulse is as follows.

function Tn = rectangularLoad(load,location,state,T)
if isnan(state.time)
    Tn = NaN*(location.nx);
    return
end
if isa(load,"function_handle")
    load = load(location,state);
else
    load = load(:);
end
% Two time-points that define a rectangular pulse
T1 = T(1); % Start time
T2 = T(2); % End time

% Determine multiplicative factor for the specified time.
TnTrap = max([(state.time - T1)*(T2 - state.time)/ ...
               abs((state.time - T1)*(T2 - state.time)),0]);
Tn = load.* TnTrap;
end

Thermal Analysis

Convert the code for analyzing the heat distribution in a block with a cavity from the domain-specific workflow, which uses a ThermalModel object, to the unified workflow, which uses an femodel object.

Domain-Specific WorkflowUnified Workflow
%% Heat Transfer in Block with Cavity

% Create a model and include the block geometry.
model = createpde("thermal","transient");
geometryFromEdges(model,@crackg);

% Specify the thermal conductivity, mass density, and specific heat.
thermalProperties(model,ThermalConductivity=1, ...
                        MassDensity=1,SpecificHeat=1);

% Specify the temperature on edge 6.
thermalBC(model,Edge=6,Temperature=100);

% Specify constant heat flow to the exterior through edge 1.
thermalBC(model,Edge=1,HeatFlux=-10);

% Set the initial temperature.
thermalIC(model,0);

% Generate a mesh.
generateMesh(model);

% Solve the problem for times between 0 and 5 seconds.
result = solve(model,0:0.5:5)
%% Heat Transfer in Block with Cavity

% Create a model and include the block geometry.
model = femodel(AnalysisType="thermalTransient", ...
                Geometry=@crackg);

% Specify the thermal conductivity, mass density, and specific heat.
model.MaterialProperties = materialProperties(ThermalConductivity=1, ...
                           MassDensity=1,SpecificHeat=1);

% Specify the temperature on edge 6.
model.EdgeBC(6) = edgeBC(Temperature=100);

% Specify constant heat flow to the exterior through edge 1.
model.EdgeLoad(1) = edgeLoad(Heat=-10);

% Set the initial temperature.
model.FaceIC = faceIC(Temperature=0);

% Generate a mesh and assign it to the model.
model = generateMesh(model);

% Solve the problem for times between 0 and 5 seconds.
result = solve(model,0:0.5:5)

Electromagnetic Analysis

Convert the code for analyzing the electrostatic potential in an air-filled annular quadrilateral frame from the domain-specific workflow, which uses an ElectromagneticModel object, to the unified workflow, which uses an femodel object.

Domain-Specific WorkflowUnified Workflow
%% Electrostatic Potential in Air-Filled Frame

% Create a model and assign a geometry.
model = createpde("electromagnetic","electrostatic");
importGeometry(model,"Frame.stl");

% Specify the vacuum permittivity value in the SI system of units.
model.VacuumPermittivity = 8.8541878128e-12;

% Specify the relative permittivity of the material.
electromagneticProperties(model,RelativePermittivity=1.00059);

% Specify the electrostatic potential at the inner boundary.
electromagneticBC(model,Voltage=1000,Edge=[1 2 4 6]);

% Specify the electrostatic potential at the outer boundary.
electromagneticBC(model,Voltage=0,Edge=[3 5 7 8]); 

% Generate a mesh.
generateMesh(model);

% Solve the problem.
result = solve(model)
%% Electrostatic Potential in Air-Filled Frame

% Create a model and include the frame geometry.
model = femodel(AnalysisType="electrostatic", ...
                    Geometry="Frame.stl");

% Specify the vacuum permittivity value in the SI system of units.
model.VacuumPermittivity = 8.8541878128e-12;

% Specify the relative permittivity of the material.
model.MaterialProperties = materialProperties(RelativePermittivity=1.00059);

% Specify the electrostatic potential at the inner boundary.
model.EdgeBC([1 2 4 6]) = edgeBC(Voltage=1000);

% Specify the electrostatic potential at the outer boundary.
model.EdgeBC([3 5 7 8]) = edgeBC(Voltage=0);

% Generate a mesh and assign it to the model.
model = generateMesh(model);

% Solve the problem.
result = solve(model)

Related Topics