How to generate code in MATLAB for randomly oriented short fibers?
9 次查看(过去 30 天)
显示 更早的评论
I need to generate an input file in MATLAB and run in ABAQUS.
wrote some input accordingly as follows:
%% Monte Carlo style script for random placement of fibres
%% Block 1: Define RVE Space
RVE_Length = 100; %Length
RVE_Width = 100; %Width
D = 15; %Fibre Diameter
VolFract = 30; %Percentage volume fraction
%Define RVE
figure('Name','RVE with random fibres','NumberTitle','off')
rveBox = axes('Box','on');
xlim([0 RVE_Length]);
ylim([0 RVE_Width]);
xlabel('RVE Length, L (\mum)')
ylabel('RVE Width, W (\mum)')
title('Random positioned fibres RVE')
%% Block 2: Determine total number of fibres, N_total
Ntotal = round( (0.01*VolFract*RVE_Length*RVE_Width)/(pi*D^2) );
disp(['Total Number of Fibre, Ntotal = ',num2str(Ntotal)]);
%% Block 3: Generate random position of first fibre
XYALL(:,:) = zeros; % A hold-all variable for all fibre coordinates
XYALL(1,1) = rand*RVE_Length; %Random x-position for 1st fibre
XYALL(1,2) = rand*RVE_Width; %Random y-position for 1st fibre
Dmin=0.1; R=D/2; Ncurrent = 0.1;
%% Block 4: Check overlap criteria
phi = 20; %Percentage of R parameter
for Ni = 2:Ntotal
while Dmin < 2*R*(1+phi)
%Create a test position [xtest, ytest] to see if it overlaps
xtest = rand*RVE_Length; %Random x-position for next fibre
ytest = rand*RVE_Width; %Random y-position for next fibre
for i = 1:Ncurrent
% Include codes here to test for overlap
% for all current fibre existing in RVE
end
end
% Accept into XYALL the tested coordinate position
% when they pass the overlap test
XYALL(Ni,1) = xtest;
XYALL(Ni,2) = ytest;
end
%% Block 6: Implementation of periodicity of material
b = cell(1);
for m = 1:length(xEdgeFibres) %For xEdge Fibres Only
if XYALL(xEdgeFibre(m),1)<R
b(m) = [XYALL(xEdgeFibres(m),1)+RVE_Length XYALL(xEdgeFibres(m),2) ];
else
b(m) = [XYALL(xEdgeFibres(m),1)-RVE_Width XYALL(xEdgeFibres(m),2) ];
end
end
%Repeat similar coding for yEdgeFibres and cornerFibres
Unfortunately code is not able to run as desired. Kindly help with above code how to generate input files and run into MATLAB and ABAQUS.
2 个评论
KSSV
2023-1-9
Why do you think code is unable to run? What problem you are facing? You need to specify your error exactly.
采纳的回答
Walter Roberson
2023-1-10
while Dmin < 2*R*(1+phi)
%Create a test position [xtest, ytest] to see if it overlaps
xtest = rand*RVE_Length; %Random x-position for next fibre
ytest = rand*RVE_Width; %Random y-position for next fibre
for i = 1:Ncurrent
% Include codes here to test for overlap
% for all current fibre existing in RVE
end
end
Your while tests a relationship between Dmin and R and phi . The while loop body might not be entered at all (depending on the initial values), but if it is entered, then the while loop will continue until the condition stops holding or until there is a break statement encountered. In order for the condition to stop holding, at least one of the variables involved in the relationship being tested, must change inside the loop. If all of the variables involved in the relationship are constants inside the loop body and there is no break then the value of the relationship cannot change, so if the loop body were ever entered then it could not possibly be exited.
12 个评论
Walter Roberson
2023-1-12
https://www.mathworks.com/matlabcentral/answers/405186-fill-area-with-random-circles-having-different-diameters#comment_1236758 has code for filling space with ellipsoids. Fibres can be modeled as ellipsoids with a long major axes and short minor axes.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!