Exporting image-generated geometry in matlab to FEA compatible format
2 次查看(过去 30 天)
显示 更早的评论
- Hello, I am doing an undergraduate thesis, and I like to implement MATLAB in some of the analysis.
- The query is, how to export a file generated as an image in a code, to a format compatible with FEA (Finite element analysis).
- The goal is to find the temperature profile in this slag pot geometry, which is a truncated cone.
- So, once having the compatible geometry I can use matlab pdegplot and some commands related to find the temperature profile.
- The code was generated by AI (Claude).
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 - R1) / h * Z + R1;
B = (b1 - b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceAlpha', 0.7); % Superficie lateral
fill3(x1, y1, z1, 'r'); % Base inferior
fill3(x2, y2, z2, 'b'); % Base superior
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
title('Tronco de Cono con Bases Elípticas');
axis equal;
grid on;
hold off;
1 个评论
dpb
2024-8-6
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 - R1) / h * Z + R1;
B = (b1 - b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceAlpha', 0.7); % Superficie lateral
fill3(x1, y1, z1, 'r'); % Base inferior
fill3(x2, y2, z2, 'b'); % Base superior
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
title('Tronco de Cono con Bases Elípticas');
axis equal;
grid on;
hold off;
view([-37.5 30]) % lets look at a 3D view
For FEA modeling, you need the mesh coordinates and connectivity. Is your intent to export to an external FEA code like Ansys for the computation or do it all in MATLAB? There's generateMesh in the PDE Toolbox and some examples
回答(1 个)
Rahul
2024-8-7
According to my understanding you wish to export the values generated by your code to an format conmpatible with FEA.
From the code provided by you, you can consider exporting your values to an '.stl' file which is a common format for FEA.
In addition to the code provided by you, you can do the following steps:
% Convert surface data to patch data
[F, V] = surf2patch(X, Y, Z, 'triangles');
% Create a triangulation object
TR = triangulation(F, V);
% Write the triangulation data to an STL file
stlwrite(TR, 'truncated_cone.stl');
Here the 'surf2patch' function is used to convert the surface data (X, Y, Z) into a patch structure returning Faces(F) and Vectices(V) of the object.
The 'triangulation' function takes the Faces(F) and Vertices(V) and creates a traingulation object (TR) which can be used to define geometry of the obejcts.
The 'stlwrite' function takes the 'triangulation' object (TR) and writes it's geometrical structure in a '.stl' format.
You can refer to the following documentations to know more about these functions:
'surf2patch' : https://www.mathworks.com/help/releases/R2024a/matlab/ref/surf2patch.html?searchHighlight=surf2patch&s_tid=doc_srchtitle
'triangulation' : https://www.mathworks.com/help/releases/R2024a/matlab/ref/triangulation.html?searchHighlight=triangulation&s_tid=doc_srchtitle
'stlwrite' : https://www.mathworks.com/help/releases/R2024a/matlab/ref/stlwrite.html?searchHighlight=stlwrite&s_tid=doc_srchtitle
Hope this helps! Thanks.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General PDEs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!