Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Hi

Please login with a confirmed email address before reporting spam

I modeled a geometry in matlab, can any one tell me how to import that geometry to comsol

6 Replies Last Post 2017年6月5日 GMT-4 11:31

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2014年7月29日 GMT-4 02:45
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: 10 years ago 2014年8月7日 GMT-4 05:00
I modeled spheres randomly in space
I modeled spheres randomly in space

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 2014年8月12日 GMT-4 03:55
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: 10 years ago 2014年8月12日 GMT-4 06:17
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: 10 years ago 2014年8月12日 GMT-4 07:44
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 2017年6月5日 GMT-4 11:31
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,

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.