Commit 94328883 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm unused example ParticleComposition

parent 3efadcfa
Pipeline #33374 passed with stage
in 19 minutes and 58 seconds
#!/usr/bin/env python3
"""
"""
import bornagain as ba
from bornagain import deg, nm, kvector_t
from matplotlib import pyplot as plt
# Sample model parameters
particle_radius = 2.5*nm
lattice_length = 10*nm
height = 50*nm
def get_sample(hasVariance):
# 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 Layers
l_air = ba.Layer(m_air)
l_substrate = ba.Layer(m_substrate)
# Define Form Factors
ff = ba.FormFactorFullSphere(particle_radius)
# Define composition of particles at specific positions
particle_composition = ba.ParticleComposition()
# compute number of particles in the vertical direction
n = int((height - 2*particle_radius) // lattice_length)
# add particles to the particle composition
for i in range(n+1):
particle = ba.Particle(m_particle, ff)
particle_position = kvector_t(0, 0, i*lattice_length)
particle.setPosition(particle_position)
particle_composition.addParticle(particle)
# Define Interference Function
lattice = ba.SquareLattice2D(lattice_length, 0*deg)
interference = ba.InterferenceFunction2DLattice(lattice)
interference_pdf = ba.FTDecayFunction2DCauchy(500*nm, 500*nm, 0)
interference.setDecayFunction(interference_pdf)
if hasVariance:
interference.setPositionVariance(0.3*nm)
# interference.setIntegrationOverXi(True) # slow!
# Define Particle Layout and add Particles
layout = ba.ParticleLayout()
layout.addParticle(particle_composition)
layout.setInterferenceFunction(interference)
# Add layout to layer
l_air.addLayout(layout)
# Define Multilayers
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, nPlot, title):
sample = get_sample(hasVariance)
simulation = get_simulation(sample)
simulation.runSimulation()
result = simulation.result()
plt.subplot(1, 2, nPlot)
return ba_plot.plot_colormap(result,
title=title,
# xlabel=r'$X_{mm}$',
# ylabel=r'$Y_{mm}$',
intensity_max=3e8,
intensity_min=3e1,
zlabel=None,
aspect='equal',
with_cb=False)
if __name__ == '__main__':
import ba_plot
fig, axs = plt.subplots(2, 1, figsize=(12.80, 10.24))
im = run_one(False, 1, "fixed positions")
run_one(True, 2, "position variance 0.3 nm")
plt.subplots_adjust(bottom=0, left=0.1)
plt.colorbar(im, cax=plt.axes([0.93, 0.27, 0.03, 0.34]))
plt.show()
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