Ejemplo n.º 1
0
def runSimulation():
    # defining materials
    mAmbience = ba.HomogeneousMaterial("Air", 0.0, 0.0)
    mSubstrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8)

    magnetic_field = ba.kvector_t(0, 0, 0)

    magParticle = ba.HomogeneousMaterial("magParticle", 6e-4, 2e-8,
                                         magnetic_field)
    # collection of particles
    cylinder_ff = ba.FormFactorCylinder(5 * nanometer, 5 * nanometer)
    cylinder = ba.Particle(magParticle, cylinder_ff)

    particle_layout = ba.ParticleLayout()
    particle_layout.addParticle(cylinder, 1.0)
    interference = ba.InterferenceFunctionNone()
    particle_layout.setInterferenceFunction(interference)

    # air layer with particles and substrate form multi layer
    air_layer = ba.Layer(mAmbience)
    air_layer.addLayout(particle_layout)
    substrate_layer = ba.Layer(mSubstrate, 0)
    multi_layer = ba.MultiLayer()
    multi_layer.addLayer(air_layer)
    multi_layer.addLayer(substrate_layer)

    # build and run experiment
    simulation = ba.GISASSimulation()
    simulation.setDetectorParameters(100, 0 * degree, 2.0 * degree, 100,
                                     0.0 * degree, 2.0 * degree)
    simulation.setBeamParameters(1.0 * angstrom, 0.2 * degree, 0.0 * degree)
    simulation.setSample(multi_layer)
    simulation.runSimulation()
    ## intensity data
    return simulation.getIntensityData()
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    def get_sample(self, particle):
        mAmbience = ba.HomogeneousMaterial("Air", 0.0, 0.0)
        mMiddle= ba.HomogeneousMaterial("Teflon", 2.900e-6, 6.019e-9)
        mSubstrate = ba.HomogeneousMaterial("Substrate", 3.212e-6, 3.244e-8)

        layout = ba.ParticleLayout()
        layout.addParticle(particle)

        air_layer = ba.Layer(mAmbience)
        middle_layer = ba.Layer(mMiddle, layer_thickness)
        middle_layer.addLayout(layout)
        substrate = ba.Layer(mSubstrate)

        multi_layer = ba.MultiLayer()
        multi_layer.addLayer(air_layer)
        multi_layer.addLayer(middle_layer)
        multi_layer.addLayer(substrate)
        return multi_layer
Ejemplo n.º 5
0
"""
Functional test to check slicing mechanism for spherical particles
when they are crossing an interface.
"""

from __future__ import print_function
import os, sys, unittest

import utils
import libBornAgainCore as ba
from libBornAgainCore import deg, kvector_t

mSubstrate = ba.HomogeneousMaterial("Substrate", 3.212e-6, 3.244e-8)
mAmbience = ba.HomogeneousMaterial("Air", 0.0, 0.0)


class SlicedSpheresTest(unittest.TestCase):
    def get_sample(self, particle_to_air=None, particle_to_substrate=None):
        """
        Helper function returning a multilayer (air, substrate) using particles provided
        by the user.
        """

        air_layer = ba.Layer(mAmbience)
        if particle_to_air:
            layout = ba.ParticleLayout()
            layout.addParticle(particle_to_air)
            air_layer.addLayout(layout)

        substrate = ba.Layer(mSubstrate)
        if particle_to_substrate:
Ejemplo n.º 6
0
"""
Functional test to check slicing mechanism for particle compositions
when they are crossing an interface.
"""

from __future__ import print_function
import os, sys, unittest

import utils
import libBornAgainCore as ba
from libBornAgainCore import deg, kvector_t, nm

mSubstrate = ba.HomogeneousMaterial("Substrate", 3.212e-6, 3.244e-8)
mAmbience = ba.HomogeneousMaterial("Air", 0.0, 0.0)
mParticle = ba.HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7)
sphere_radius = 10.0
bottom_cup_height = 4.0


class SlicedSpheresTest(unittest.TestCase):
    def get_sample(self, particle_to_air=None, particle_to_substrate=None):
        """
        Helper function returning a multilayer (air, substrate) using particles provided
        by the user.
        """

        air_layer = ba.Layer(mAmbience)
        if particle_to_air:
            layout = ba.ParticleLayout()
            layout.addParticle(particle_to_air)
            air_layer.addLayout(layout)