def test_optimise_materials(self, simple_object): domain = PySALEDomain(simple_object) domain.fill_with_random_grains_to_threshold( PySALEObject.generate_ellipse([0, 0], .5, .5, 0, 1), 50.) domain.optimise_materials() materials = {grain.material for grain in domain.object.children} assert len(materials) == 9
from PySALESetup.mesh import ExtensionZone, Region, \ ExtensionZoneFactor import matplotlib.pyplot as plt # Construct 4 extension zones: one for each region extension_zones = [ ExtensionZone(15, region, 1., ExtensionZoneFactor(1.05, 20)) for region in [Region.NORTH, Region.SOUTH, Region.EAST, Region.WEST] ] # Build a mesh using the extension zones m = PySALEMesh(100, 100, extension_zones=extension_zones, cell_size=1.) object1 = PySALEObject.generate_ellipse([56, 56], 50., 50., material=1, rotation=0) object2 = PySALEObject.generate_ellipse([159, 159], 50., 50., material=2, rotation=0) object3 = PySALEObject.generate_ellipse([107.2, 107.2], 50., 50., material=3, rotation=0) m.project_polygons_onto_mesh([object1, object2, object3])
from PySALESetup import PySALEObject, PySALEDomain, PySALEMesh import matplotlib.pyplot as plt main = PySALEObject.generate_ellipse([5., 5.], 5., 5., 0.) main.set_material(1) domain = PySALEDomain(main) circle = PySALEObject.generate_ellipse([0., 0.], .5, .5, 0.) circle.set_as_void() domain.fill_with_random_grains_to_threshold(circle, 40) mesh = PySALEMesh(100, 100, cell_size=.1) for child in main.children: child.set_as_void() mesh.project_polygons_onto_mesh([main]) mesh.plot_materials() main.plot() plt.show()
(0.001, 0.003), (0, 0.003)]) host.set_material(0) back_plate = PySALEObject([(0, 0.0002), (0.001, 0.0002), (0.001, 0.001), (0, 0.001)]) back_plate.set_material(1) # Create a domain object which will perform the particle insertions domain = PySALEDomain(host) # Create a particle to be used for insertion # Its centroid does not matter here as we'll just move it around # anyway, so use [0, 0] particle = PySALEObject.generate_ellipse([0, 0], 50e-6, 50e-6, 0, 1) domain.fill_to_threshold_area(particle, 40) # Optimise particle materials so that none touch of the same material domain.optimise_materials([2, 3, 4, 5, 6, 7, 8, 9]) # plot the geometries we've created fig, ax = host.plot() impactor.plot(ax) back_plate.plot(ax) plt.show() # Create the mesh onto which we'll apply these geometries mesh_1 = PySALEMesh(100, 500, cell_size=10.e-6) # Apply/project the geometries onto our mesh for geometry in [host, impactor, back_plate]: mesh_1.apply_geometry(geometry)
def object_with_weibull_distributions(): object_ = PySALEObject.generate_ellipse([0, 0], 2, 1, 0) radii = PySALEWeibull2Distribution(1, 1) areas = PySALEWeibull2Distribution(pi, pi) angles = PySALEWeibull2Distribution(0, 180) return object_, radii, areas, angles
def object_with_uniform_distributions(): object_ = PySALEObject.generate_ellipse([0, 0], 2, 1, 0) radii = PySALEUniformDistribution((.5, 2)) areas = PySALEUniformDistribution((pi * .5, pi * 2)) angles = PySALEUniformDistribution((0, 360)) return object_, radii, areas, angles
def circle(): return PySALEObject.generate_ellipse([5., 5.], 1., 1., 0.)