Make an offset on a stl file like with the multicuboid function

6 views (last 30 days)
Hello eveyrone,
I have this stl file below and I would like to do a layer of a different material as with the offset of the multicuboid function.
I don't know if it is possible to do it with an stl file.
I also made a canteliver with the multicuboid function with a layer on top of a different material but I don't succeed to make "holes" to reproduce this structure. I tried with the addVoid function but it doesn't work.
Here is the beginning of the code with the multicuboid function :
clc
clear vars
close all
% Create a PDE model for a modal analysis
modelModal_TP2 = createpde("structural","modal-solid");
% Dimensions of the canteliver
L = 75e-6;
l = 9e-6;
h = 1.2e-6;
% Geometry of the canteliver
gm1 = multicuboid(L,l,h);
% Geometry to do the hole in the first geometry
gm2 = multicuboid(45e-6,3e-6,h);
translate(gm2,[-15e-6 0 0]);
% g3 = addVoid(gm,gm1);
figure;
pdegplot(gm1)
hold on
pdegplot(gm2)
% figure;
% pdegplot(g3,"FaceLabels","on")
Thank you in advance

Answers (1)

Drishti
Drishti on 3 Oct 2024
Hi Alex,
I understand that you are trying to create 'holes' in the 3d geometry. On reproducing the provided code on my end, I faced a similar issue.
One possible work around to rectify the problem of ‘holes’ is by utilizing the Antenna Toolbox, which offers the ‘subtract’ function for 3D geometries.
You can refer to the provided implementation for better understanding:
% Geometry of the cantilever
gm1 = multicuboid(L, l, h);
% Geometry for the hole in the first geometry
gm2 = multicuboid(45e-6, 3e-6, h);
translate(gm2, [-15e-6, 0, 0]);
% Subtract gm2 from gm1 to create a void using Antenna Toolbox
% Convert to Antenna Toolbox format
cantilever = antenna.Rectangle('Length', L, 'Width', l, 'Center', [L/2, l/2]);
void = antenna.Rectangle('Length', 45e-6, 'Width', 3e-6, 'Center', [15e-6, 1.5e-6]);
% Perform subtraction
resultingGeometry = subtract(cantilever, void);
You can also refer to the MATLAB Documentation of ‘subtract’ function available in Antenna Toolbox.
I hope this resolves the query.
  3 Comments
Drishti
Drishti on 4 Oct 2024
Hi Alex,
If you could provide the use case of your code and what exactly the code is for, we might be able to help.
Alex
Alex on 4 Oct 2024
Edited: Alex on 5 Oct 2024
@Drishti below is the code for the modal analysis of a simple cantilever and I want to do it with the complex cantilever I showed in the first message.
clc
clear vars
close all
% Create a PDE model for modal analysis of a solid structure
model = createpde("structural","modal-solid");
% Beam dimensions
a = 75e-6; % Length (in meters)
b = 9e-6; % Width (in meters)
h = 1.4e-6; % Thickness (in meters)
% Material properties (Silicon)
E = 160e9; % Young's modulus (Pa)
rho = 2300; % Density (kg/m^3)
nu = 0.23; % Poisson's ratio
% Beam geometry
gm = multicuboid(a, b, h);
figure;
pdegplot(gm, "FaceLabels", "on")
view(30,30);
title("Simple Cantilever")
% Assign the geometry to the model
model.Geometry = gm;
% Mechanical properties of the material
structuralProperties(model,'YoungsModulus',E,'PoissonsRatio',nu,'MassDensity',rho);
% Boundary conditions (Fixed on one face)
structuralBC(model,'Face',5,'Constraint','fixed');
% Mesh generation
generateMesh(model);
% Display the mesh
figure;
pdeplot3D(model);
title('Mesh of the simple cantilever');
% Analytical result for the first natural frequency for verification
I = h^3/12; % Moment of inertia
analyticalF0 = 3.516*sqrt(E*I/(a^4*(rho*h)))/(2*pi); % First natural frequency
% Solve the modal problem within a frequency range
modalResults = solve(model,"FrequencyRange",[0,1e7]*2*pi);
% Display the natural frequencies
disp('Values of natural frequencies:');
Values of natural frequencies:
disp(modalResults.NaturalFrequencies/(2*pi));
1.0e+06 * 0.3369 2.1085 2.1360 5.3871 5.8956
% Plot the mode shapes in 3D
for i = 1:length(modalResults.NaturalFrequencies)
figure;
pdeplot3D(model, 'ColorMapData', modalResults.ModeShapes.ux(:,i));
title(['Eigen mode ',num2str(i),' with frequency ',num2str(modalResults.NaturalFrequencies(i)/(2*pi)),' Hz']);
end
So my difficulty is only to create the geometry in Matlab because I can't import a .stl file to do this because it as to be a two layered cantilever with the ZOffset argument in the multicuboid function like below but with the complex shape :
clc
clear vars
close all
% Create a PDE model for a modal analysis
modelModal_TP2 = createpde("structural","modal-solid");
% Dimensions of the canteliver
L = 75e-6;
l = 9e-6;
width1=1.2e-6;
width2=0.2e-6;
% Geometry of the cantilever
gm1 = multicuboid(L, l, [width1,width2], 'Zoffset',[0 width1]);
figure;
pdegplot(gm1);

Sign in to comment.

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!