Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
bca3da13
Commit
bca3da13
authored
4 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
start analysis of parameter distribution
parent
84a07f73
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
devtools/architecture/ParameterDistribution.md
+117
-0
117 additions, 0 deletions
devtools/architecture/ParameterDistribution.md
devtools/architecture/Scattering.md
+2
-1
2 additions, 1 deletion
devtools/architecture/Scattering.md
with
119 additions
and
1 deletion
devtools/architecture/ParameterDistribution.md
0 → 100644
+
117
−
0
View file @
bca3da13
## Parameter distributions
Analysis of BornAgain develop, per 3dec20.
It seems there are two different ways for handling parameter distributions,
the one specifically for particle distributions, the other one more generic.
### Particle distribution
#### Typical use
Typical use of parameter distributions is described in
`Examples/Python/sim01_Particles/CylindersWithSizeDistribution.py`
:
```
def get_sample():
# Define materials and form factor ...
# Define particles
particle = ba.Particle(material_Particle, ff)
# Define particles with parameter following a distribution
distr_1 = ba.DistributionGaussian(5.0*nm, 1.0*nm)
par_distr_1 = ba.ParameterDistribution(
"/Particle/Cylinder/Radius", distr_1, 100, 2.0)
particle_distrib = ba.ParticleDistribution(particle, par_distr_1)
# Define particle layouts
layout = ba.ParticleLayout()
layout.addParticle(particle_distrib, 1.0)
# Define layers
layer = ba.Layer(material_Vacuum)
layer.addLayout(layout)
# Define sample
sample = ba.MultiLayer()
sample.addLayer(layer)
return sample
def get_simulation():
simulation = ba.GISASSimulation()
simulation.setDetectorParameters(200, 0.0*deg, 2.0*deg, 200, 0.0*deg, 2.0*deg)
simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg)
return simulation
def run_simulation():
simulation = get_simulation()
simulation.setSample(get_sample())
simulation.runSimulation()
return simulation.result()
```
#### What goes on behind the scenes?
Class hierarchy:
```
IParametricComponent
- INode
- ISampleNode
- IAbstractParticle
- ParticleDistribution (final)
- IParticle
- Particle (final)
- ParticleCoreShell (final)
... (all final)
- ISampleBuilder
- DistributionHandler (final)
- ParameterDistribution (final)
```
As we see from the
`CylindersWithSizeDistribution`
example,
a
`ParticleDistribution`
is bound to a
`ParticleLayout`
.
The drawing of
`IParticle`
s from the distribution happens here:
```
SafePointerVector<IParticle> ParticleLayout::particles() const {
SafePointerVector<IParticle> particle_vector;
for (const auto* particle : m_particles) {
if (const auto* p_part_distr = dynamic_cast<const ParticleDistribution*>(particle)) {
SafePointerVector<IParticle> generated_particles = p_part_distr->generateParticles();
for (const IParticle* particle : generated_particles)
particle_vector.push_back(particle->clone());
} else if (const auto* p_iparticle = dynamic_cast<const IParticle*>(particle)) {
particle_vector.push_back(p_iparticle->clone());
}
}
return particle_vector;
}
```
### Generic distribution handler
This mechanism acts almost on top of the simulation model hierarchy.
`ISimulation`
has member
`DistributionHandler m_distribution_handler`
.
It is modified through
`ISimulation::addParameterDistribution`
.
This function is called explicitly by some standard simulations and Python scripts
(e.g.
`sim03_Structures/Interference2DLatticeSumOfRotated.py`
),
but not in the above simple example.
```
void ISimulation::runSimulation() {
...
size_t param_combinations = m_distribution_handler.getTotalNumberOfSamples();
std::unique_ptr<ParameterPool> param_pool(createParameterTree());
for (size_t index = 0; index < param_combinations; ++index) {
double weight = m_distribution_handler.setParameterValues(param_pool.get(), index);
runSingleSimulation(batch_start, batch_size, weight);
}
m_distribution_handler.setParameterToMeans(param_pool.get());
...
}
```
This diff is collapsed.
Click to expand it.
devtools/architecture/Scattering.md
+
2
−
1
View file @
bca3da13
## How does BornAgain compute scattering?
## How does BornAgain compute scattering?
Code analysis per 18nov, after merge of https://github.com/scgmlz/BornAgain/pull/1105.
Analysis of BornAgain develop, per 18nov,
after merge of https://github.com/scgmlz/BornAgain/pull/1105.
### Simulation computes an incoherent sum
### Simulation computes an incoherent sum
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment