FE Model with function handle

5 views (last 30 days)
Geovane Gomes
Geovane Gomes on 1 Jul 2024
Answered: Umar on 2 Jul 2024
Hello everyone.
Is it possible to use a function handle within a femodel? So I could change the value of a material property or load, for example:
gm = multicuboid(0.5,0.1,0.1);
pdegplot(gm,FaceLabels="on",FaceAlpha=0.5);
% without function handles
model = femodel(AnalysisType="structuralStatic", ...
Geometry=gm);
E = 210e3;
P = 1000;
nu = 0.3;
model.MaterialProperties = materialProperties(YoungsModulus=E,PoissonsRatio=nu);
model.FaceLoad(2) = faceLoad(Pressure=P);
model.FaceBC(5) = faceBC("Constraint","fixed");
model = generateMesh(model);
r = solve(model);
pdeplot3D(r.Mesh,"Deformation",r.Displacement,"ColorMap",r.VonMisesStress);
% using function handles
model = femodel(AnalysisType="structuralStatic", ...
Geometry=gm);
E = @(x) x(1);
P = @(x) x(2);
model.MaterialProperties = materialProperties(YoungsModulus=E,PoissonsRatio=nu);
model.FaceLoad(2) = faceLoad(Pressure=P);
model.FaceBC(5) = faceBC("Constraint","fixed");
model = generateMesh(model);
values = [210e3 1000];
r = solve(model(values)); % I know it's wrong, once variable model has only one element, but I want to replace YoungsModulus property by values(1) and faceLoad(2) by values(2)
Index exceeds the number of array elements. Index must not exceed 1.
pdeplot3D(r.Mesh,"Deformation",r.Displacement,"ColorMap",r.VonMisesStress);

Answers (1)

Umar
Umar on 2 Jul 2024
Hi Geovane,
You asked Is it possible to use a function handle within a femodel? So I could change the value of a material property or load.
My answer is yes, it is possible to employ function handles within a femodel in Matlab. By utilizing function handles, you can dynamically adjust material properties or loads during the simulation process. This flexibility allows for the creation of more versatile and adaptive femodels that can respond to changing conditions or requirements.
Hope that answers your question.

Tags

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!