Getting error while solving PDE

3 views (last 30 days)
AD
AD on 18 Aug 2023
Answered: Karan Singh on 28 Aug 2023
I am trying to solve this equation for thermal stress analysis.
The greens functions are as follows:
I have written the following code. But I am getting a error. How to resolve the issue? If the approacj is wrong, how to go about solving it?
function u = thermal_stress(T)
% Initialize the variables
a =
1e-5; % thermal expansion coefficient
E =
200e9; % Young's modulus
v =
0.3; % Poisson's ratio
p =
1; % load
% Discretize the domain
x =
linspace(0, 1, 100);
z =
linspace(0, 1, 100);
[X, Z] =
meshgrid(x, z);
% Create the mesh
mesh = pde.Mesh(X, Z);
% Define the boundary conditions
bc = pde.DirichletBC(mesh,
0, 'x');
bc = [bc; pde.DirichletBC(mesh,
0, 'z')];
% Define the Green's function
G(x, z) = Zp / (
2(1 - v')^2) * (1 / (x + 2) + 1 / (z + 2));
% Define the temperature equation
T = (
0.1/sqrt(x^2+z^2))*(exp(-0.1*((sqrt(x^2 + z^2)+x)/2*3.75*10^(-6)))
% Define the PDE
eqn = a*E*(
1-2*v)*T*pde.Laplacian(u) - a*E*(1-2*v)*T;
% Solve the equation
u = pde.solve(eqn, bc, mesh);
end

Answers (1)

Karan Singh
Karan Singh on 28 Aug 2023
Hey AD, I had a look through your code and found that the functions that you have been using currently has no MATLAB documentation and would have previously belonged to R2022b, not to the one I am using R2023a. However here a demo code I can provide to get you started on PDE.
% Define the PDE problem
% Step 1: Define the PDE coefficients, boundary conditions, and initial conditions
% Create a PDE model
model = createpde();
% Step 2: Specify the geometry
% Use either geometryFromEdges or geometryFromMesh to define the geometry
% Step 3: Specify the boundary conditions
% Use applyBoundaryCondition to specify the boundary conditions
% Step 4: Specify the PDE coefficients and source term
% Use specifyCoefficients to specify the PDE coefficients and source term
% Step 5: Solve the PDE
result = solvepde(model);
% Step 6: Extract and analyze the solution
% Extract the solution using the result.Mesh and result.NodalSolution properties
% Analyze the solution as needed (e.g., plot, compute derived quantities)
% Example: Plot the solution
pdeplot(model, 'XYData', result.NodalSolution);
You may need to refer to the PDE Toolbox documentation and examples for more detailed information and specific usage of functions mentioned above.

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!