def test_export(self): NUM_INCLUSIONS = 4 INCLUSION_SIZE = 0.2 #Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) inclusion_material2 = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion2', youngs_modulus=2500, poissons_ratio=0.2) inclusion_materials = [ inclusion_material, inclusion_material, inclusion_material2, inclusion_material ] matrix_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Matrix', youngs_modulus=3000, poissons_ratio=0.25) #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Constant(INCLUSION_SIZE, NUM_INCLUSIONS) loc = Locations.FixedLocation(generate_lattice=True, num_locations=4) circles = Locations.Location.GenerateInclusions( NUM_INCLUSIONS, dist, loc, inclusion_materials) output = Shapes.Circle.ExportInclusions(circles) print output
def test_guassian_circles_visual(self): NUM_INCLUSIONS = 10 #Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS max_radius = Shapes.Circle.determine_max_radius(0, 3, 1) #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Gaussian(max_radius / 2, max_radius / 2, NUM_INCLUSIONS) loc = Locations.FixedLocation(generate_lattice=True, num_locations=NUM_INCLUSIONS, buffersize=0, scalefactor=1) circles = Locations.Location.GenerateInclusions(NUM_INCLUSIONS, dist, loc, inclusion_materials, recurse_attempts=5, max_attempts=50) LocationsTests.setupboundingbox() print 'Generated {0} circles'.format(len(circles)) for circle in circles: LocationsTests.drawCircle(circle.centre, circle.radius)
def test_lattice_constructor(self): loc = Locations.FixedLocation(generate_lattice=True, num_locations=4) self.assertEqual(4, len(loc.locations)) self.assertTrue((0.25, 0.25) in loc.locations) self.assertTrue((0.25, 0.75) in loc.locations) self.assertTrue((0.75, 0.25) in loc.locations) self.assertTrue((0.75, 0.75) in loc.locations)
def test_fixed_random_order(self): """ Note that this test can technically fail. If the random function randomly puts the 10 objects back in the same order, then it will fail. That should only happen 1 in 3.6 million times the test is run though, so it should be fine. """ locs = [(0.1, 0.1), (0.2, 0.2), (0.3, 0.3), (0.4, 0.4), (0.5, 0.5), (0.6, 0.6), (0.7, 0.7), (0.8, 0.8), (0.9, 0.9)] fixed_loc = Locations.FixedLocation(locs, True) self.assertNotEqual(locs, fixed_loc.locations)
def test_generate_circles(self): NUM_INCLUSIONS = 4 INCLUSION_SIZE = 0.2 #Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Constant(INCLUSION_SIZE, NUM_INCLUSIONS) loc = Locations.FixedLocation(generate_lattice=True, num_locations=4) circles = Locations.Location.GenerateInclusions( NUM_INCLUSIONS, dist, loc, inclusion_materials)
#Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) inclusion_mesh = [Mesh.Mesh(elem_shape=abaqusConstants.QUAD)] * NUM_INCLUSIONS #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Ellipse.Constant(0.3, 0.15, NUM_INCLUSIONS) loc = Locations.FixedLocation(generate_lattice=True, num_locations=NUM_INCLUSIONS) ellipses = Locations.Location.GenerateInclusions( NUM_INCLUSIONS, dist, loc, inclusion_materials, inclusion_shape=Shapes.shapes.ELLIPSE, recurse_attempts=10) inclusions = zip(ellipses, inclusion_mesh) #Output the details of the generated shapes. It will be located in the directory the script is run from(should eb the abaqus temp directory export_str = Shapes.Ellipse.ExportInclusions(ellipses) with open("geometry.txt", "w") as text_file: text_file.write(export_str)
def creation_helper(self): loc = [(0.5, 0.5)] return Locations.FixedLocation(loc)