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 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 testBoxTransform(self): """ Reference box of (10,50,20) size is compared against the box (50,20,10) with two rotations applied to get reference one """ mParticle = ba.HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7) # reference box length = 10 width = 50 height = 20 box = ba.Particle(mParticle, ba.FormFactorBox(length, width, height)) box.setPosition(kvector_t(0, 0, -layer_thickness/2 - height/2)) reference_data = self.get_result(box) #IntensityDataIOFactory.writeIntensityData(reference_data, "ref_TransformBox.int") # second box length = 50 width = 20 height = 10 box = ba.Particle(mParticle, ba.FormFactorBox(length, width, height)) box.setRotation(ba.RotationZ(90*deg)) box.rotate(ba.RotationY(90*deg)) box.setPosition(kvector_t(0, 0, -layer_thickness/2)) data = self.get_result(box) diff = ba.RelativeDifference(data, reference_data) print(diff) self.assertLess(diff, 1e-10)
def testSpheresCrossingInterface(self): """ Compares two simulation intended to provide identical results. Simulation #1: full sphere inserted in air layer to cross interface Simulation #2: full sphere inserted in substrate layer to cross interface Both spheres are made of same material. """ mParticle = ba.HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7) sphere_radius = 10.0 sphere_shift = 4.0 # shift beneath interface in absolute units # Sphere intended for air layer and crossing interface sphere1 = ba.Particle(mParticle, ba.FormFactorFullSphere(sphere_radius)) sphere1.setPosition(0, 0, -sphere_shift) reference = self.get_result(particle_to_air=sphere1) # Sphere intended for substrate layer and crossing interface sphere2 = ba.Particle(mParticle, ba.FormFactorFullSphere(sphere_radius)) sphere2.setPosition(0, 0, -sphere_shift) data = self.get_result(particle_to_substrate=sphere2) 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_result(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_result(composition) diff = ba.RelativeDifference(data, reference) print(diff) self.assertLess(diff, 1e-10)
def testCompositionBuilds(self): """ Compares two simulation intended to provide identical results. Simulation #1: spherical particle composition on top of substrate Simulation #2: same, but made using rotation """ composition = self.get_composition(mParticle, mSubstrate) reference = self.get_result(composition) # spherical composition composition2 = self.get_composition_v2(mParticle, mSubstrate) data = self.get_result(composition2) diff = ba.RelativeDifference(data, reference) print(diff) self.assertLess(diff, 1e-10)
def testComposition(self): """ Compares two simulation intended to provide identical results. Simulation #1: spherical particle on top of substrate Simulation #2: spherical composition on top of substrate, where top and bottom are made of same material """ # spherical particle sphere = ba.Particle(mParticle, ba.FormFactorFullSphere(sphere_radius)) reference = self.get_result(sphere) # spherical composition composition = self.get_composition(mParticle, mParticle) data = self.get_result(composition) diff = ba.RelativeDifference(data, reference) print(diff) self.assertLess(diff, 1e-10)
def testInvisibleComposition(self): """ Compares two simulation intended to provide identical results. Simulation #1: no particles at all Simulation #2: spherical composition on top of substrate crossing the interface Bottom part of composition is made of substrate material, top part from air layer material """ shift = bottom_cup_height # Scattering from empty multilayer reference = self.get_result() # spherical composition composition = self.get_composition(mAmbience, mSubstrate) composition.setPosition(0, 0, -shift) data = self.get_result(composition) diff = ba.RelativeDifference(data, reference) print(diff) self.assertLess(diff, 1e-10)
def testSlicedComposition(self): """ Compares two simulation intended to provide identical results. Simulation #1: spherical particle on top of substrate Simulation #2: spherical composition on top of substrate, where top and bottom are made of same material Both particles are inserted in air layer with shift to go below interface """ shift = 3 * nm # spherical particle sphere = ba.Particle(mParticle, ba.FormFactorFullSphere(sphere_radius)) sphere.setPosition(0, 0, -shift) reference = self.get_result(sphere) # spherical composition composition = self.get_composition(mParticle, mParticle) composition.setPosition(0, 0, -shift) data = self.get_result(composition) diff = ba.RelativeDifference(data, reference) print(diff) self.assertLess(diff, 1e-10)