This live script is written as a guided walkthrough for a verification benchmark. It compares a known structural response with the result produced by the OpenSeesMatlab workflow. Read the text cells first, then run each code cell in order so that the variables, model state, and recorded results are available for the later sections.
Perform a 2-D plane-stress elasticity analysis.
A thin rectangular plate under a uniaxial tension has a uniform stress distribution. Introducing a circular hole in the plate disturbs the uniform stress distribution near the hole, resulting in a significantly higher than average stress. Such a thin plate, subject to in-plane loading, can be analyzed as a 2-D plane-stress elasticity problem. In theory, if the plate is infinite, then the stress near the hole is three times higher than the average stress. For a rectangular plate of finite width, the stress concentration factor is a function of the ratio of hole diameter to the plate width. This example approximates the stress concentration factor using a plate of a finite width.
The following commands carry out this step of the workflow. Run this cell after the previous sections so the required variables and model state already exist.
1 2 3 4 5 6 7 8 910111213141516171819
clc;clear;closeall;radius=20.0;totalWidth=50.0;totalLength=4*totalWidth;R1=[34-totalLengthtotalLength...totalLength-totalLength...-totalWidth-totalWidthtotalWidthtotalWidth]';C1=[100radius000000]';gdm=[R1C1];ns=char('R1','C1');g=decsg(gdm,'R1 - C1',ns');figurepdegplot(g,EdgeLabel="on");axis([-1.2*totalLength1.2*totalLength-1.2*totalWidth1.2*totalWidth])title("Geometry with Edge Labels")
1234
figurepdegplot(g,VertexLabels="on");axis([-1.2*totalLength1.2*totalLength-1.2*totalWidth1.2*totalWidth])title("Geometry with Vertex Labels")
R=solve(model);maxUxPDE=max(R.Displacement.ux);maxVonMisesStressPDE=max(R.VonMisesStress);maxSxxPDE=max(R.Stress.sxx);figurepdeplot(R.Mesh,XYData=R.Displacement.ux,...ColorMap="jet")axisequaltitle("Displacement Along x-Direction")
12345
figurepdeplot(R.Mesh,XYData=R.Stress.sxx,...ColorMap="jet")axisequaltitle("Normal Stress Along x-Direction")
mesh=model.Mesh;% PDE mesh% Nodes : 2 x nNode% Elements : 3 x nElemnodes=mesh.Nodes.';% nNode x 2elems=mesh.Elements.';% nElem x 3nNode=size(nodes,1);nElem=size(elems,1);ifsize(elems,2)~=3error('This conversion script expects a linear triangular mesh.');end%% ------------------------------------------------------------------------% 3) Identify boundary entities from PDE labels%% ------------------------------------------------------------------------loadEdgeID=2;fixEdgeID=4;fixVertexID=1;loadNodeIDs=unique(findNodes(mesh,"region","Edge",loadEdgeID));fixEdgeNodes=unique(findNodes(mesh,"region","Edge",fixEdgeID));fixVertNodes=unique(findNodes(mesh,"region","Vertex",fixVertexID));loadNodeIDs=loadNodeIDs(:);fixEdgeNodes=fixEdgeNodes(:);fixVertNodes=fixVertNodes(:);%% ------------------------------------------------------------------------% 4) Build boundary segments on the loaded edge%% ------------------------------------------------------------------------TR=triangulation(elems,nodes);bedges=freeBoundary(TR);% nb x 2 boundary node pairsisLoadSeg=all(ismember(bedges,loadNodeIDs.'),2);loadSegs=bedges(isLoadSeg,:);ifisempty(loadSegs)warning('No boundary segments found on PDE edge %d.',loadEdgeID);end%% ------------------------------------------------------------------------% 5) Convert edge traction to equivalent nodal loads%% For a 2-node linear boundary segment:% f_e = \int N^T t * thk ds% For constant traction:% f_e = (L*thk/2) * [tx; ty; tx; ty]%% ------------------------------------------------------------------------thickness=1;% choose consistent thickness for Tri31traction=[100;0];% same as PDE edge loadnodalLoads=zeros(nNode,2);fori=1:size(loadSegs,1)s=loadSegs(i,:);x1=nodes(s(1),:);x2=nodes(s(2),:);L=norm(x2-x1);fe=(L*thickness/2)*[traction(:);traction(:)];% 4x1nodalLoads(s(1),:)=nodalLoads(s(1),:)+fe(1:2).';nodalLoads(s(2),:)=nodalLoads(s(2),:)+fe(3:4).';end
[OpenSeesMatlab] Model summary
Nodes: 4072
Plane elements: 7808
1234567
nodeResp=opsMAT.post.getNodalResponse("myODB");ux=nodeResp.disp.ux;maxUx=max(ux(:));fprintf("Maximal deflection in the x-direction:\n"+..." OpenSeesMatlab: %g meters\n"+..." MATLAB PDE : %g meters\n",...maxUx,maxUxPDE);
Output
Maximal deflection in the x-direction:
OpenSeesMatlab: 0.222333 meters
MATLAB PDE : 0.222333 meters
123456789
opts=opsMAT.vis.defaultPlotNodalResponseOptions;opts.fixed.show=false;opts.surf.showEdges=false;opts.deform.show=false;opsMAT.vis.plotNodalResponse(nodeResp,respType="disp",stepIdx="absMax",respComponent="UX",opts=opts);colormap("jet")axisofftitle("Displacement Along x-Direction")
Maximal Von Mises stress:
OpenSeesMatlab: 317.613 Pa
MATLAB PDE : 317.613 Pa
1 2 3 4 5 6 7 8 910
opts=opsMAT.vis.defaultPlotContinuumResponseOptions;opts.fixed.show=false;opts.surf.showEdges=false;opts.deform.show=false;opsMAT.vis.plotContinuumResponse(planeResp,...respType="StressMeasureAtNode",respComponent="sxx",opts=opts);axisequalcolormap("jet")title("Normal Stress Along x-Direction")