def testSphericalLacuneInSubstrate(self): """ Similar to previous. Truncated sphere and sphere are made of air material. From scattering point of view, both cases should look like an air lacune in substrate. """ sphere_radius = 10.0 sphere_shift = 4.0 # shift beneath interface in absolute units # Sphere truncated from top. Intended to go below interface. truncatedSphere = ba.Particle( mAmbience, ba.FormFactorTruncatedSphere(sphere_radius, sphere_radius * 2, sphere_radius * 2 - sphere_shift)) truncatedSphere.setPosition(0, 0, -sphere_shift) reference = self.get_result(truncatedSphere) # sphere crossing interface to look like truncated sphere above sphere = ba.Particle(mAmbience, ba.FormFactorFullSphere(sphere_radius)) sphere.setPosition(0, 0, -sphere_shift) data = self.get_result(sphere) diff = ba.RelativeDifference(data, reference) print(diff) self.assertLess(diff, 1e-10)
def testSphericalCupOnTopOfSubstrate(self): """ Compares two simulation intended to provide identical results. Simulation #1: truncated sphere on top of substrate. Simulation #2: spherical particle crossing the interface. Both particles are made of same material as substrate. From scattering point of view, both cases should look like a truncated sphere on top of substrate. """ sphere_radius = 10.0 sphere_shift = 4.0 # shift beneath interface in absolute units # truncated sphere on top of substrate with height 16nm truncatedSphere = ba.Particle( mSubstrate, ba.FormFactorTruncatedSphere(sphere_radius, sphere_radius * 2 - sphere_shift)) reference = self.get_result(truncatedSphere) # sphere crossing interface to look like truncated sphere above sphere = ba.Particle(mSubstrate, ba.FormFactorFullSphere(sphere_radius)) sphere.setPosition(0, 0, -sphere_shift) data = self.get_result(sphere) diff = ba.RelativeDifference(data, reference) print(diff) self.assertLess(diff, 1e-10)
def testSphericalCupOnTopOfSubstrate(self): """ Compares two simulation intended to provide identical results. Simulation #1: truncated sphere on top of substrate. Simulation #2: spherical particle composition crossing the interface. Bottom part of composition is made from substrate material. both cases should look like a truncated sphere on top of substrate. """ # truncated sphere on top of substrate with height 16nm truncatedSphere = ba.Particle( mParticle, ba.FormFactorTruncatedSphere(sphere_radius, sphere_radius * 2 - bottom_cup_height)) reference = self.get_intensity_data(truncatedSphere) # Particle composition, top part made of same material, as particle. Bottom part made of same material as substrate. composition = self.get_composition(mParticle, mSubstrate) composition_shift = bottom_cup_height composition.setPosition(0, 0, -composition_shift) data = self.get_intensity_data(composition) diff = ba.getRelativeDifference(data, reference) print(diff) self.assertLess(diff, 1e-10)
def get_composition_v2(self, top_material, bottom_material): """ Returns particle composition representing sphere made of two different materials. Alternative to previous method. Rotation is used to get bottom part """ topCup = ba.Particle( top_material, ba.FormFactorTruncatedSphere(sphere_radius, sphere_radius * 2 - bottom_cup_height)) bottomCup = ba.Particle( bottom_material, ba.FormFactorTruncatedSphere(sphere_radius, bottom_cup_height)) bottomCup.setRotation(ba.RotationX(180 * deg)) # origin of resulting sphere will be at the bottom result = ba.ParticleComposition() result.addParticle(topCup, kvector_t(0.0, 0.0, bottom_cup_height)) result.addParticle(bottomCup, kvector_t(0.0, 0.0, bottom_cup_height)) return result
def get_composition(self, top_material, bottom_material): """ Returns particle composition representing sphere made of two different materials. Origin of new object is at the bottom of resulting sphere. """ topCup = ba.Particle( top_material, ba.FormFactorTruncatedSphere(sphere_radius, sphere_radius * 2 - bottom_cup_height)) bottomCup = ba.Particle( bottom_material, ba.FormFactorTruncatedSphere(sphere_radius, sphere_radius * 2, sphere_radius * 2 - bottom_cup_height)) # origin of resulting sphere will be at the bottom result = ba.ParticleComposition() result.addParticle(topCup, kvector_t(0.0, 0.0, bottom_cup_height)) result.addParticle(bottomCup, kvector_t(0.0, 0.0, 0.0)) return result