How to export a randomly generated spheres in a volume in Matlab to ANSYS?

  • 875 Views
  • Last Post 12 January 2020
  • Topic Is Solved
auob07 posted this 29 March 2019

I want to develop model of a a cube with sand particles (Spheres) inside. I want to analyze it in ANSYS. Spheres are randomly generated in Matlab as shown in the Figure. I want to export the geometry to ANSYS and mesh it.

Order By: Standard | Newest | Votes
SandeepMedikonda posted this 30 March 2019

ANSYS is CAD Neutral. Write it out in one of the formats such as para solid etc. and import it back into Design Modeler or SpaceClaim.

Help

  • Liked by
  • auob07
peteroznewman posted this 30 March 2019

Here is a matlab script that exports IGES files, which you could open directly using SpaceClaim.

Since you have some programming skills aoub07, you can learn the scripting language of SpaceClaim and have the script read a simple text file of the x, y, z, r values of the center and radius of the spheres, then have the SpaceClaim script create the spheres.

  • Liked by
  • auob07
rwoolhou posted this 05 April 2019

I'm sure I answered this question a few days ago: there are journal features in SpaceClaim that'll help with this. Note, you'll need to make sure the spheres don't touch otherwise the mesh count will most likely be too high to solve on the Student software.

  • Liked by
  • auob07
auob07 posted this 05 December 2019

Hey Ayoo713

 

 

# Python Script, API Version = V17

ClearAll()

path = r"C:\Users\X260\spheres.csv"

# Load file

sphere_dims = []

with open(path,'r') as f:

    sphere_dims = f.readlines()

for line in sphere_dims:

    # For each line we divide number by ;

    line = line.split(',')

    line = [float(val) for val in line]

    # Créer une sphère

    SphereBody.Create(Point.Create(MM(line[0]), MM(line[1]), MM(line[2])), Point.Create(MM(line[3]), MM(line[4]), MM(line[5])), ExtrudeType.None, Info1)

    # EndBlock

print('Well done')

# EndBlock

 

  • Liked by
  • Ayoo713
auob07 posted this 03 April 2019

I have the coordinates of each sphere (x,y,z,r) and I want to know how to gener the geometry.

auob07 posted this 05 April 2019

I created the geometry in Spaceclaim. Thank you all.

 

 

 

sudhir249 posted this 18 April 2019

Hey aub07

Is it possible to make that packing in a cylindrical container ?

I made a packing in blender (exported as .stl file) but is giving me errors during meshing

Could you help me out here ?

Hadi posted this 13 May 2019

auob07

I have the same problem. I imported the file from MATLAB using space claim but I couldn't mesh the generated geometry. Could u plz help me in doing that.

auob07 posted this 16 May 2019

Hey Hadi 

Can you describe the problem

auob07 posted this 16 May 2019

Hey

Yes you can

Marek11x posted this 13 September 2019

Hey auob07,

 

I have a similaer problem  with a lot of spheres with (x,y,z,R) and the transfer to ANSYS spaceclaim. How did you import it into the space claim? Can you help me with the code?

auob07 posted this 13 September 2019

Hey Marek

To import the spheres to SpaceClaim I used a Python code.

Ayoo713 posted this 05 December 2019

hey auob07

could you please share how you imported the spheres using a python code onto spaceclaim, because I am trying to import something similar and I don't know how.

thnx

 

ansysuser posted this 06 December 2019

 Hello auob07,

Are those spheres solid bodies or surface bodies? I need to import a solid body which has two boundaries into SC and I am having trouble in another post on this cite.  Do you think python would work for something like this as well?

Ayoo713 posted this 07 December 2019

hey auob07,

 

thank u for your fast reply, I tried to import my coordinates using your code but I have only the center-points of the spheres and not the endpoints .are there any commands to generate spheres with only center-points in spaceclaim?

these are my coordinates:

 

5.36930529738153,8.4155428348086,4.36542790618492

8.72656102670593,3.46830251052839,6.55139832270416

6.28323924328875,5.30184538919145,6.52830667872247

6.28469778134021,2.5169176550141,2.13027644671986

8.85021023058322,2.46282753594592,1.39419796600096

2.6118136190826,3.98874237356829,4.69701595225187

4.44649987588356,4.86130722571652,2.07316684209528

5.90331041998632,3.18923393535679,7.50243614790944

 

ankita1815 posted this 18 December 2019

hey auob07,

I am facing the same issue described by Ayoo713. if you have a solution to that please let me know or describe what is endpoints of a sphere and how to get endpoints of a sphere.

ankita1815 posted this 19 December 2019

hey auob07,

can you please describe what is endpoints of a sphere and how to get those endpoints. I have .csv file which contains information about centroid locations (x,y, and z) and radius only. I am not able to run the script in SpaceClaim described by you. can you please help me?

auob07 posted this 19 December 2019

Hey

I'm sorry for the late reply, I had exams.

Endpoint is a point M on the surface of the sphere.

M=O+R; where O is the center and R is the radius 

so we can generate the coordinnates of M by adding R to X, Y or Z coordonates of O ( I added R to Z).

 

sndeeep84 posted this 21 December 2019

Hello,

I have created the sphere in MATLAB but how to import those files in spaceclaim with the help of script.

Attached Files

desouzadacosta posted this 12 January 2020

No luck with your script -(

Is that r in path = r"C:\Users\X260\spheres.csv" a typo ?

Also no luck with the script below :

# Python Script, API Version = V17
# User Inputs
fid = open("C:\Users\413x4ndr3\Documents\packed-spheres-sc\coords.csv",'r')
Rad = 2.5
#Radius in mm
# Create Sphere
for line in fid:
    line = line.split(',')
    x = float(line[0])
    y = float(line[1])
    z = float(line[2])
    SphereBody.Create(Point.Create(MM(x), MM(y), MM(z)), Point.Create(MM(x+Rad), MM(y), MM(z)), ExtrudeType.None, Info2)
    mode = InteractionMode.Solid
    result = ViewHelper.SetViewMode(mode, Info3)
fid.close()

 

Anybody please help us.

Close