Pipe elbow creation using MATLAB code

조회 수: 19 (최근 30일)
Md Mia
Md Mia 2023년 1월 5일
댓글: Md Mia 2023년 7월 25일
Hi
I am done with my MATLAB code which creates as many straight pipes I want. However, I want to connect them using pipe elbow looks like below. Any idea how to create this elbow in MATLAB?
  댓글 수: 2
John D'Errico
John D'Errico 2023년 1월 5일
What does CREATING it mean? As after all, you already have a picture of what you want, and MATLAB is not a tool I would probably use to drive a CNC mill. A 90 degree elbow like that might be a difficult project to make anyway, even if I did have a million dollars of tooling on hand. Anyway, a pipe elbow like that would probably be formed using a hot extrusion process, and then bent into shape. And that means if I did want to create that object, a pipe bender would be the tool of choice. Just throw some heavy duty hydraulics at the problem.
Ok, that is all irrelevant, since I assume you want to make something in MATLAB, purely for graphics purposes. And for that, you already have all the curve radii, so all you needs are some circle segments, unless you also want pretty shading and lighting.
So what are you looking for here?
Md Mia
Md Mia 2023년 1월 23일
편집: Md Mia 2023년 1월 23일
Thanks. Here is the way I tried to model the elbow using MATLAB. My target is to attach two pipes with this 90 degree elbow. At first I modleed a bent curve (basically the center line of the elbow - blue line in the fig below). Now knowing the x,y,z coordiantes of the points on the curve, I created 3d circles along those points and it looks like below. However, when I was trying to connect it with first straight pipe, it's not working. Is there any mistake I am doing during elbow modeling.
%% elbow inputs
pipe_size = 25.4; % in mm
d_outside = 33.4; % in mm
A = 38; % in mm (center-to-end distance) % Ref. 1 (page 16, Table 3)
% long radius elbow is used where radius of curvature is greater than pipe diamter (>= 1.5*pipe diamater)
% For 90° Long Radius elbows, center to end dimension given in dimension tables of ASME B16.9 is same as radius of elbow (Ref. 2)
x1 = 2100; % left_pipe_end_x
y1 = 0.00; % left_pipe_end_yo
x2 = 2138; % right_pipe_end_x
y2 = -38; % right_pipe_end_y
R = 38; % radius of curvature in mm
%% now let's calculate center point (x0,y0)
syms x0 y0
eq1 = R^2-((x0-x1)^2 + (y0-y1)^2);
eq2 = R^2-((x0-x2)^2 + (y0-y2)^2);
sol=solve([eq1,eq2,x0<=x1,y0<=y2],[x0,y0]);
x_c = double(sol.x0)
y_c = double(sol.y0)
%(x0,y0) = (2138,0)
%% other points
x = linspace(x1,x2,50);
x = x';
for i = 1:length(x)
x1 = x(i);
eqa1 = @(y) R^2 - ((x_c-x1)^2 + (y_c-y)^2);
format long g
y_l = [0 -38];
y(i) = fzero(eqa1,y_l);
end
y = y';
final_mat = [x,y];
plot(final_mat(:,1), final_mat(:,2), 'b-', 'LineWidth', 2)
hold on
load output;
for i = 1:length(final_mat(:,1))
[x_value{i},y_value{i},z_value{i}] = plotCircle3D ([x(i),y(i),0], [1,0,0], d_outside/2, n_ele_circum);
end
function [x_value,y_value,z_value] = plotCircle3D(center, normal, radius, n_ele_circum)
d_theta = 2*pi/n_ele_circum; % increment size
theta = 0:d_theta:(2*pi-d_theta); % in radian
v=null(normal);
points=repmat(center',1,size(theta,2))+radius*(v(:,1)*cos(theta)+v(:,2)*sin(theta));
plot3(points(1,:),points(2,:),points(3,:),'r-');
x_value = points(1,:);
y_value = points(2,:);
z_value = points(3,:);
end

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2023년 1월 25일
편집: John D'Errico 2023년 1월 25일
What is not working? Why do you think it is not working?
I would conjecture that one problem you have is you cannot model a 90 degree elbow as you tried to do. Your circles are drawn always parallel to each other. And that MUST be incorrect.
A second problem is you are drawing only circles. They will have no connection to each other along the length of the elbow. And that two will be a problem. So do this better by drawing a true surface, as what I would call a 2-manifold. Setting it up to follow a curve in space is a good idea.
The nice thing is, this makes it also trivial to generate a series of pipes, because the cylinder code I wrote does not care if the centerline path is a linear segment or a circular arc. For example
[pipe1x,pipe1y,pipe1z] = generalCylinder([-1 1 0;0 1 0],0.25,50);
[pipe2x,pipe2y,pipe2z] = generalCylinder([1 0 0;1 -1 0],0.25,50);
phi = linspace(0,pi/2)';
elbowarcxyz = 1*[cos(phi),sin(phi),zeros(numel(phi),1)];
[elbowx,elbowy,elbowz] = generalCylinder(elbowarcxyz,0.25,50);
H1 = surf(pipe1x,pipe1y,pipe1z);
hold on
H2 = surf(pipe2x,pipe2y,pipe2z);
H3 = surf(elbowx,elbowy,elbowz);
H1.FaceColor = 'b';
H2.FaceColor = 'g';
H3.FaceColor = 'r';
box on
hold off
axis equal
I attached generalCylinder to this answer.
Now all you need do is create a centerline path through space, and then use the cylinder code to build the cylinder as a surface that follows that path.
  댓글 수: 7
Md Mia
Md Mia 2023년 4월 22일
편집: Md Mia 2023년 4월 22일
HI
I was using general cylinder code of @John D'Errico to create elbow (can be seen in previous answer of this thread). However, when I opened the file in LSDyna, I found that the created elbow not exactly connects with the other two pipes as can be seen from the figure below. As can be seen, in some connected portions, there are gaps and some parts there are overlap at the connnection side between pipe and elbow. I will be grateful if someone can help me in this case. Thanks again.The code (code2.m) is attached herein which can also be found in previous answer of @John D'Errico.
Md Mia
Md Mia 2023년 7월 25일
If pipe 1 end nodes and elbow 1 front nodes can be made having exactly similar coordiantes, this issue was resolved. Due to some differences in the coordinates, this problem was arising but works good now.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by