Bug #2477
Core: FF: support rotation of Box around x or y axis
Status: | Backlog | Start date: | 22 Sep 2020 | |
---|---|---|---|---|
Priority: | High | Due date: | ||
Assignee: | wuttke | % Done: | 0% | |
Category: | - | |||
Target version: | - |
Description
Example from Chang-Yong Kim, Chang-Yong.Kim@lightsource.ca, 21sep20
from matplotlib import pyplot as plt import numpy as np import bornagain as ba from bornagain import deg, angstrom, nm, nm2, kvector_t height = 38.66*nm cube_sigma = 0.15 shell = 7.0 * nm shell_sigma = 0.8 cut = 7.0 * nm offset = 0.0 intensity = 1.0e7 background = 68.0 alpha_i = 0.1498 * deg horizontal_slice_value = 94.0 vertical_slice_value = 81.0 x_sigma = 5.0 def get_sample(rotx): # Defining Materials material_1 = ba.HomogeneousMaterial("Air", 0.0, 0.0) material_2 = ba.HomogeneousMaterial("hematite", 1.557e-05, 9.418e-07) material_3 = ba.HomogeneousMaterial("carbon", 5.67e-06, 7.4019e-09) material_4 = ba.HomogeneousMaterial("Si", 6.075e-06, 1.1264e-07) # Defining Layers layer_1 = ba.Layer(material_1) layer_2 = ba.Layer(material_4) # Defining Form Factors formFactor_1 = ba.FormFactorBox(height, height, height) formFactor_2 = ba.FormFactorBox(height + 2. * shell, height + 2. * shell, height + shell + offset) # Defining Particles particle_1 = ba.Particle(material_2, formFactor_1) particle_2 = ba.Particle(material_3, formFactor_2) core_position = ba.kvector_t(0.0, 0.0, offset) # Set rotation around X (beam direction) particle_rotation = ba.RotationX(rotx * deg) particle_1.setRotation(particle_rotation) particle_2.setRotation(particle_rotation) # Defining Core Shell Particles particleCoreShell_1 = ba.ParticleCoreShell(particle_2, particle_1, core_position) print(particleCoreShell_1.parametersToString()) # Defining Particle Layouts layout_1 = ba.ParticleLayout() layout_1.addParticle( particleCoreShell_1) # Adding layouts to layers layer_1.addLayout(layout_1) # Defining Multilayers multiLayer_1 = ba.MultiLayer() multiLayer_1.addLayer(layer_1) multiLayer_1.addLayer(layer_2) return multiLayer_1 def get_simulation(rotx): simulation = ba.GISASSimulation() detector = ba.RectangularDetector(2048, 165.0, 2048, 165.0) detector.setPerpendicularToDirectBeam(2367.622, 84.997, 82.338) simulation.setDetector(detector) simulation.setBeamParameters(0.1381 * nm, alpha_i, 0.0 * deg) simulation.setBeamIntensity(intensity) simulation.getOptions().setIncludeSpecular(True) bg = ba.ConstantBackground(background) simulation.setBackground(bg) simulation.setRegionOfInterest(45.0, 88.0, 125.0, 140.) simulation.addMask(ba.Rectangle(81.86, 82.26, 88.78, 100.79), True) # mask on reflected beam sample = get_sample(rotx) simulation.setSample(sample) return simulation def run_simulation(): hist = ba.Histogram2D(2048, 0.0, 165.0, 2048, 0.0, 165.0) hist_crop = hist.crop(45.0, 88.0, 125.0, 140.) passarg = x_sigma simulation = get_simulation(passarg) simulation.runSimulation() return simulation.result() if __name__ == '__main__': result = run_simulation() ba.plot_simulation_result(result, cmap='jet', aspect='auto')
fails with
terminate called after throwing an instance of 'std::runtime_error' what(): Box::createSlicedFormFactor error: not supported for the given rotation!
History
#4 Updated by wuttke about 2 months ago
- Priority changed from Urgent to High
#5 Updated by wuttke about 2 months ago
- Status changed from Sprint to Backlog