[Yade-users] [Question #706022]: Is it possible to add hue to each radii sphere radius? Also, after simulation is my calculation wrong?
New question #706022 on Yade: https://answers.launchpad.net/yade/+question/706022 import random import math from yade import geom, pack, utils from yade import export import numpy as np # Define cylinder parameters center = (0, 0, 0) radius = 0.08 height = 0.10 # create cylindrical body with radius 0.08 m and height 0.0605 m cylinder = yade.geom.facetCylinder(center=center, radius=radius, height=height, segmentsNumber=80, wallMask=6) O.bodies.append(cylinder) # Define sphere parameters and percentages radii = [0.75, 0.0006, 0.00236, 0.00475, 0.0095, 0.0125] percentages = [0.04, 0.06, 0.05, 0.35, 0.2, 0.3] # Generate sphere pack sp = pack.SpherePack() for r, ratio in zip(radii, percentages): num_spheres = int(ratio * 1000) sp.makeCloud((-0.055,-0.055,0.35), (0.055,0.055,0.01), rMean=r, rRelFuzz=0, num=num_spheres) # add the sphere pack to the simulation sp.toSimulation() # Define gravity engine O.engines = [ForceResetter(), InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]), InteractionLoop( [Ig2_Sphere_Sphere_ScGeom6D(), Ig2_Facet_Sphere_ScGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_ScGeom_FrictPhys_CundallStrack()] ), GlobalStiffnessTimeStepper(defaultDt=0.0001, timestepSafetyCoefficient=0.8), NewtonIntegrator(gravity=(0,0,-9.81), damping=0.4), ] # Define simulation duration and time step O.dt = 1e-5 O.run(1000) # Count the number of spheres in the cylinder num_spheres_in_cylinder = 0 for body in O.bodies: if body.id == 0: # skip the cylinder continue sphere_center = body.state.pos dist_to_axis = math.sqrt(sphere_center[0]**2 + sphere_center[1]**2) if dist_to_axis <= radius and sphere_center[2] >= center[2] and sphere_center[2] <= center[2] + height: num_spheres_in_cylinder += 1 # Calculate volume of spheres in cylinder volume_of_spheres_in_cylinder = 0 for body in O.bodies: if body.id == 0: # skip the cylinder continue sphere_center = body.state.pos dist_to_axis = math.sqrt(sphere_center[0]**2 + sphere_center[1]**2) if dist_to_axis <= radius and sphere_center[2] >= center[2] and sphere_center[2] <= center[2] + height: if isinstance(body.shape, Sphere): # check if body is a sphere sphere_volume = (4/3) * math.pi * body.shape.radius**3 volume_of_spheres_in_cylinder += sphere_volume # Calculate volume of cylinder volume_of_cylinder = (math.pi * radius**2) * height # Calculate porosity porosity = (volume_of_cylinder - volume_of_spheres_in_cylinder) / volume_of_cylinder porosity_percent = porosity * 100 # Print results print("Number of spheres in cylinder:", num_spheres_in_cylinder) print("Volume of spheres in cylinder:", volume_of_spheres_in_cylinder) print("Volume of cylinder:", volume_of_cylinder) print("Porosity:", porosity) print("Porosity:", porosity_percent, "%") I have two question 1. Is it possible to add color to each radii sphere radius? 2. After simulation, the sphere seems to pack well in the container, but my porosity after calculation if above 80+% did I have mistake in my calculation process? -- You received this question notification because your team yade-users is an answer contact for Yade. ___ Mailing list: https://launchpad.net/~yade-users Post to : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
Re: [Yade-users] [Question #706005]: I am trying to create a simulation within yade with different sphere radius to fall by gravity into a container
Question #706005 on Yade changed: https://answers.launchpad.net/yade/+question/706005 Jan Stránský posted a new comment: If you have a new problem, please open a new question Cheers Jan -- You received this question notification because your team yade-users is an answer contact for Yade. ___ Mailing list: https://launchpad.net/~yade-users Post to : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
Re: [Yade-users] [Question #706005]: I am trying to create a simulation within yade with different sphere radius to fall by gravity into a container
Question #706005 on Yade changed: https://answers.launchpad.net/yade/+question/706005 Status: Answered => Solved Huan confirmed that the question is solved: Thanks Jan Stránský, that solved my question. -- You received this question notification because your team yade-users is an answer contact for Yade. ___ Mailing list: https://launchpad.net/~yade-users Post to : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
Re: [Yade-users] [Question #706005]: I am trying to create a simulation within yade with different sphere radius to fall by gravity into a container
Question #706005 on Yade changed: https://answers.launchpad.net/yade/+question/706005 Status: Open => Answered Jan Stránský proposed the following answer: Hello, > V packing and V cylinder are calculated as 0 > Why does the calculation is calculated as 0? it is not computed as 0, it is just printed as 0.00 Change "{:.2f}" e.g. to "{:e}" or even just "{}" to see the actual value [1,3] :.2f rounds the number to two decimal numbers, but the actual value is much less, so 0.00 is printed, even if the number is not zero. > Is there any guide on how to make the sphere pack better in the container? See gravity deposition tutorial [2] > the simulation doesn't fully packed > O.run(1000) because it runs too little time (?) Also consider using ### O.run(1000,wait=True) ### or ### O.run(1000) O.wait() ### If you have a python code after O.run(1000), it is executed "immediately", i.e. at a random time w.r.t. running simulation Or go in the [3] style with checkUnbalanced-like stop condition. A few not important notes: > print("Number of spheres:", "{:.2f}".format(num_spheres)) "{:d}" makes much more sense for number (integer) Also consider using f-strings [3] > cylinder = yade.geom.facetCylinder(..., radius=0.06, ...) > volume_cylinder = math.pi * 0.06**2 * 0.0605 you have repeated value 0.06 It is a good practice to make it a variable then ### radius = 0.06 cylinder = yade.geom.facetCylinder(..., radius=radius, ...) volume_cylinder = math.pi * radius**2 * 0.0605 ### This way, if you want to change the radius, you just change it in one place (reducing the possible error by forgetting some place in the case where the value is at multiple places). Same for other repeated values (e.g. height) Cheers Jan [1] https://docs.python.org/3/library/string.html#formatstrings [2] https://yade-dem.org/doc/tutorial-examples.html#gravity-deposition [3] https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals -- You received this question notification because your team yade-users is an answer contact for Yade. ___ Mailing list: https://launchpad.net/~yade-users Post to : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp
Re: [Yade-users] [Question #706002]: which software is best for home appliance and auto repairs
Question #706002 on Yade changed: https://answers.launchpad.net/yade/+question/706002 Status: Open => Invalid Jan Stránský rejected the question: spam -- You received this question notification because your team yade-users is an answer contact for Yade. ___ Mailing list: https://launchpad.net/~yade-users Post to : yade-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp