Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Jul 29, 2014, 2:45 a.m. EDT
How is the geometry defined in matlab? What kind of modelling did you do with it?
How is the geometry defined in matlab? What kind of modelling did you do with it?
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Aug 7, 2014, 5:00 a.m. EDT
I modeled spheres randomly in space
I modeled spheres randomly in space
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Aug 12, 2014, 3:55 a.m. EDT
You tell me what kind of geometry you have modelled. My question was how you have written down this geometry in matlab code.
You tell me what kind of geometry you have modelled. My question was how you have written down this geometry in matlab code.
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Aug 12, 2014, 6:17 a.m. EDT
Matlab code
%Make random s p h e r e s with in a bar and p l o t
function [x1,y1,z1]=creatingspheres (x)
clc
clear all
%Volumefraction(percent)
Volumefraction=7 ;
%Volume fraction(decimal)
vf = Volumefraction/100;
%Dimensions of bar
l = 20 ;
w = 4 ;
h = 4 ;
Vbar =l*w*h;
%Numer of spheres
q = 50 ;
%Radius of spheres
r =((3*vf*(Vbar ))/(4*q*pi))^(1/3) ;
%Create initial random coordinates
x1 = (rand*(w-2*r))+r;
y1 = (rand*(h-2*r))+r ;
z1 = (rand*(l-2*r))+r ;
%Create non overlapping coordinates
m = 1 ;
t = 0 ;
while m < q
if t>1e6
error ('could not compute non over lapping co-ordinates');
break
end
Xm =(rand*(w-2*r))+r ;
Ym =(rand*(h-2*r))+r ;
Zm =(rand*(l-2*r))+r ;
C1 =(x1-Xm).^2+(y1-Ym).^2+(z1-Zm).^2;
if any(C1<4*(r ^2))
t = t+1;
continue
end
m = m+1;
x1 =[x1;Xm];
y1 =[y1;Ym];
z1 =[z1;Zm];
end
%Output sphe r e c o o r d ina t e s
[x1 y1 z1];
%Plot
[xs,ys,zs] = sphere (30);
for n = 1:m
surf ( xs*r+x1(n),ys*r+y1(n),zs*r+z1(n),'FaceColor','g','EdgeColor','r');
hold on;
camlight('left');
material dull;
end
axis equal
xlim([0 w]);
ylim([0 h]);
zlim([0 l]);
hold off;
Matlab code
%Make random s p h e r e s with in a bar and p l o t
function [x1,y1,z1]=creatingspheres (x)
clc
clear all
%Volumefraction(percent)
Volumefraction=7 ;
%Volume fraction(decimal)
vf = Volumefraction/100;
%Dimensions of bar
l = 20 ;
w = 4 ;
h = 4 ;
Vbar =l*w*h;
%Numer of spheres
q = 50 ;
%Radius of spheres
r =((3*vf*(Vbar ))/(4*q*pi))^(1/3) ;
%Create initial random coordinates
x1 = (rand*(w-2*r))+r;
y1 = (rand*(h-2*r))+r ;
z1 = (rand*(l-2*r))+r ;
%Create non overlapping coordinates
m = 1 ;
t = 0 ;
while m < q
if t>1e6
error ('could not compute non over lapping co-ordinates');
break
end
Xm =(rand*(w-2*r))+r ;
Ym =(rand*(h-2*r))+r ;
Zm =(rand*(l-2*r))+r ;
C1 =(x1-Xm).^2+(y1-Ym).^2+(z1-Zm).^2;
if any(C1
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Aug 12, 2014, 7:44 a.m. EDT
So basically you create the folowing data:
- width, lenght and height of a bar
- a radius that is the same for all balls
- an (x,y,z)-coordinate for each of the balls
A COMSOL geometry can be drawn using Matlab code which uses the above data. How exactly the LiveLink works and what the specific matlab commands are for creating spheres and bars I don't know, but you can read it in the COMSOL help/manual.
So basically you create the folowing data:
- width, lenght and height of a bar
- a radius that is the same for all balls
- an (x,y,z)-coordinate for each of the balls
A COMSOL geometry can be drawn using Matlab code which uses the above data. How exactly the LiveLink works and what the specific matlab commands are for creating spheres and bars I don't know, but you can read it in the COMSOL help/manual.
Walter Frei
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
7 years ago
Jun 5, 2017, 11:31 a.m. EDT
Hello,
You may also find this approach (new to version 5.3) helpful:
www.comsol.com/blogs/how-to-create-a-randomized-geometry-using-model-methods/
Best Regards,
Hello,
You may also find this approach (new to version 5.3) helpful:
https://www.comsol.com/blogs/how-to-create-a-randomized-geometry-using-model-methods/
Best Regards,