Commit 7cffc9b2 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Merge branch 'ex2' into 'develop'

Examples; round parameters, etc

See merge request !10
parents 6a6a3f87 8cb37c04
Pipeline #33418 passed with stage
in 19 minutes and 17 seconds
......@@ -25,7 +25,7 @@ def get_sample():
position = ba.kvector_t(0, 0, 0)
cylinder = ba.Particle(m_particle, ff.clone())
cylinder.setPosition(position)
particle_layout.addParticle(cylinder, 1)
particle_layout.addParticle(cylinder)
particle_layout.setInterferenceFunction(p_interference_function)
vacuum_layer.addLayout(particle_layout)
......
......@@ -35,9 +35,8 @@ def get_sample():
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle, 1)
layout.addParticle(particle)
layout.setInterferenceFunction(iff)
layout.setWeight(1)
layout.setTotalParticleSurfaceDensity(0.01)
# Define layers
......
......@@ -33,9 +33,8 @@ def get_sample():
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle, 1)
layout.addParticle(particle)
layout.setInterferenceFunction(iff)
layout.setWeight(1)
layout.setTotalParticleSurfaceDensity(0.0016)
# Define layers
......
......@@ -31,9 +31,8 @@ def get_sample():
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle, 1)
layout.addParticle(particle)
layout.setInterferenceFunction(iff)
layout.setWeight(1)
layout.setTotalParticleSurfaceDensity(0.0016)
# Define layers
......
......@@ -12,7 +12,7 @@ def get_sample():
"""
# Define materials
magnetic_field = kvector_t(0, 0, 10000000)
magnetic_field = kvector_t(0, 0, 1e7)
material_Particle = ba.HomogeneousMaterial("Particle", 2e-05, 4e-07,
magnetic_field)
material_Substrate = ba.HomogeneousMaterial("Substrate", 7e-06,
......@@ -47,7 +47,7 @@ def get_sample():
def get_simulation(sample):
beam = ba.Beam(1e+12, 0.1*nm, ba.Direction(0.5*deg, 0))
beam = ba.Beam(1e12, 0.1*nm, ba.Direction(0.5*deg, 0))
beam_polarization = kvector_t(0, 0, 1)
beam.setPolarization(beam_polarization)
detector = ba.SphericalDetector(200, 6*deg, 0, 3*deg)
......
File mode changed from 100644 to 100755
......@@ -51,7 +51,6 @@ def get_sample():
layout.addParticle(particle_1, 0.5)
layout.addParticle(particle_2, 0.5)
layout.setInterferenceFunction(iff)
layout.setWeight(1)
layout.setTotalParticleSurfaceDensity(0.01)
# Define layers
......
......@@ -17,7 +17,7 @@ def get_sample():
"""
# Define materials
magnetic_field = kvector_t(0, 0, 10000000)
magnetic_field = kvector_t(0, 0, 1e7)
material_Core = ba.HomogeneousMaterial("Core", 6e-06, 2e-08,
magnetic_field)
material_Shell = ba.HomogeneousMaterial("Shell", 1e-07, 2e-08)
......@@ -34,12 +34,11 @@ def get_sample():
particle_2 = ba.Particle(material_Shell, ff_2)
# Define core shell particles
particle_3 = ba.ParticleCoreShell(particle_2, particle_1)
particle = ba.ParticleCoreShell(particle_2, particle_1)
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle_3, 1)
layout.setWeight(1)
layout.addParticle(particle)
layout.setTotalParticleSurfaceDensity(0.01)
# Define layers
......@@ -57,27 +56,23 @@ def get_simulation(sample):
"""
Returns a polarized SANS simulation
"""
simulation = ba.GISASSimulation()
# Beam from above (perpendicular to sample):
beam = ba.Beam(1, 0.4*nm, ba.Direction(90*deg, 0))
beam.setPolarization(kvector_t(0, 0, 1))
# Defining detector
simulation.setDetectorParameters(200, -3*deg, 3*deg, 200, -3*deg,
3*deg)
# Detector opposite to source:
detPos = 2000 # distance from sample center to detector in mm
detWid = 500 # detector width in mm
detPix = 200 # number of pixels per direction
det = ba.RectangularDetector(detPix, detWid, detPix, detWid)
det.setPerpendicularToDirectBeam(detPos, detWid/2, detWid/2)
det.setAnalyzerProperties(kvector_t(0, 0, -1), 1, 0.5)
# Defining beam parameters
simulation.setBeamParameters(0.5*nm, 0, 0)
simulation.beam().setIntensity(1e12)
# Defining beam polarization and polarization analysis for spin-flip channel
analyzer_dir = kvector_t(0, 0, -1)
beampol = kvector_t(0, 0, 1)
simulation.beam().setPolarization(beampol)
simulation.detector().setAnalyzerProperties(analyzer_dir, 1, 0.5)
simulation.setSample(sample)
return simulation
return ba.GISASSimulation(beam, sample, det)
if __name__ == '__main__':
import ba_plot
sample = get_sample()
simulation = get_simulation(sample)
ba_plot.run_and_plot(simulation, units=ba.Axes.QSPACE)
ba_plot.run_and_plot(simulation) # TODO: restore units=ba.Axes.QSPACE)
#!/usr/bin/env python3
"""
"""
import bornagain as ba
from bornagain import deg, nm, kvector_t
from matplotlib import pyplot as plt
def get_sample(hasVariance, xi):
# Define materials
m_air = ba.HomogeneousMaterial("Air", 0, 0)
m_particle = ba.HomogeneousMaterial("Particle", 0.0006, 2e-08)
m_substrate = ba.HomogeneousMaterial("Substrate", 6e-06, 2e-08)
# Define particles
R = 2.5*nm
ff = ba.FormFactorFullSpheroid(R, R)
particle = ba.Particle(m_particle, ff)
# Define interference function
lattice = ba.SquareLattice2D(10*nm, xi)
interference = ba.InterferenceFunction2DLattice(lattice)
interference_pdf = ba.FTDecayFunction2DCauchy(500*nm, 500*nm, 0)
interference.setDecayFunction(interference_pdf)
if hasVariance:
interference.setPositionVariance(0.3*nm)
# Define particle layout
layout = ba.ParticleLayout()
layout.addParticle(particle)
layout.setInterferenceFunction(interference)
# Define layers
l_air = ba.Layer(m_air)
l_air.addLayout(layout)
l_substrate = ba.Layer(m_substrate)
# Define sample
multilayer = ba.MultiLayer()
multilayer.addLayer(l_air)
multilayer.addLayer(l_substrate)
return multilayer
def get_simulation(sample):
beam = ba.Beam(1e8, 0.1*nm, ba.Direction(0.2*deg, 0))
det = ba.SphericalDetector(400, -2*deg, 2*deg, 400, 0, 3*deg)
simulation = ba.GISASSimulation(beam, sample, det)
return simulation
def run_one(hasVariance, xi, nPlot, title):
sample = get_sample(hasVariance, xi)
simulation = get_simulation(sample)
simulation.runSimulation()
result = simulation.result()
plt.subplot(3, 2, nPlot)
return ba_plot.plot_colormap(result,
title=title,
intensity_max=3e7,
intensity_min=3e0,
zlabel=None,
aspect='equal',
with_cb=False)
if __name__ == '__main__':
import ba_plot
fig, axs = plt.subplots(3, 2, figsize=(10, 13))
xi1 = 5*deg
xi2 = 15*deg
im = run_one(False, 0*deg, 1, "xi=0 deg, fixed positions")
run_one(True, 0*deg, 2, "position variance 0.3 nm")
run_one(False, xi1, 3, "xi=5 deg, fixed positions")
run_one(True, xi1, 4, "position variance 0.3 nm")
run_one(False, xi2, 5, "xi=15 deg, fixed positions")
run_one(True, xi2, 6, "position variance 0.3 nm")
plt.subplots_adjust(bottom=0.05, left=0.1)
plt.colorbar(im, cax=plt.axes([0.93, 0.36, 0.03, 0.21]))
plt.show()
......@@ -15,14 +15,14 @@ def get_sample(lattice_rotation_angle=0*deg):
lattice_rotation_angle = 0 - beam parallel to grating lines
lattice_rotation_angle = 90*deg - beam perpendicular to grating lines
"""
# defining materials
# Define materials
m_vacuum = ba.HomogeneousMaterial("Vacuum", 0, 0)
m_si = ba.HomogeneousMaterial("Si", 5.78164736e-6, 1.02294578e-7)
m_si = ba.HomogeneousMaterial("Si", 5.7816e-6, 1.0229e-7)
box_length, box_width, box_height = 50*micrometer, 70*nm, 50*nm
lattice_length = 150*nm
# collection of particles
# Define particle layout
interference = ba.InterferenceFunction1DLattice(
lattice_length, 90*deg - lattice_rotation_angle)
......@@ -37,7 +37,7 @@ def get_sample(lattice_rotation_angle=0*deg):
ba.RotationZ(lattice_rotation_angle))
particle_layout.setInterferenceFunction(interference)
# assembling the sample
# Define sample
vacuum_layer = ba.Layer(m_vacuum)
vacuum_layer.addLayout(particle_layout)
substrate_layer = ba.Layer(m_si)
......@@ -54,7 +54,7 @@ def get_sample(lattice_rotation_angle=0*deg):
def get_simulation(sample):
beam = ba.Beam(100000000, 0.134*nm, ba.Direction(0.4*deg, 0))
beam = ba.Beam(1e8, 0.134*nm, ba.Direction(0.4*deg, 0))
detector = ba.SphericalDetector(200, -0.5*deg, 0.5*deg, 200, 0,
0.6*deg)
simulation = ba.GISASSimulation(beam, sample, detector)
......
......@@ -26,8 +26,7 @@ def get_sample():
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle, 1)
layout.setWeight(1)
layout.addParticle(particle)
layout.setTotalParticleSurfaceDensity(0.01)
# Define layers
......
......@@ -33,9 +33,8 @@ def get_sample():
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle, 1)
layout.addParticle(particle)
layout.setInterferenceFunction(iff)
layout.setWeight(1)
layout.setTotalParticleSurfaceDensity(0.00288675134595)
# Define layers
......
......@@ -28,15 +28,13 @@ def get_sample():
# Define interference functions
iff = ba.InterferenceFunction2DLattice(lattice)
iff_pdf = ba.FTDecayFunction2DGauss(159.154943092*nm, 15.9154943092*nm,
0)
iff_pdf = ba.FTDecayFunction2DGauss(160*nm, 16*nm, 0)
iff.setDecayFunction(iff_pdf)
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle, 1)
layout.addParticle(particle)
layout.setInterferenceFunction(iff)
layout.setWeight(1)
layout.setTotalParticleSurfaceDensity(0.0001)
# Define layers
......
......@@ -40,7 +40,6 @@ def get_sample():
layout = ba.ParticleLayout()
layout.addParticle(particle_distrib_1, 0.95)
layout.addParticle(particle_distrib_2, 0.05)
layout.setWeight(1)
layout.setTotalParticleSurfaceDensity(0.01)
# Define layers
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -30,8 +30,7 @@ def get_sample():
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle, 1)
layout.setWeight(1)
layout.addParticle(particle)
layout.setTotalParticleSurfaceDensity(0.01)
# Define layers
......
......@@ -48,7 +48,7 @@ def get_sample(formfactor):
# collection of particles
particle = ba.Particle(m_particle, formfactor)
particle_layout = ba.ParticleLayout()
particle_layout.addParticle(particle, 1)
particle_layout.addParticle(particle)
vacuum_layer = ba.Layer(m_vacuum)
vacuum_layer.addLayout(particle_layout)
......
......@@ -28,8 +28,7 @@ def get_sample():
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle, 1)
layout.setWeight(1)
layout.addParticle(particle)
layout.setTotalParticleSurfaceDensity(0.01)
# Define layers
......
......@@ -17,7 +17,7 @@ def get_sample():
# Define materials
material_Ambient = ba.MaterialBySLD("Ambient", 0, 0)
magnetic_field = kvector_t(0, 100000000, 0)
magnetic_field = kvector_t(0, 1e8, 0)
material_Layer = ba.MaterialBySLD("Layer", 0.0001, 1e-08,
magnetic_field)
material_Substrate = ba.MaterialBySLD("Substrate", 7e-05, 2e-06)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment