Core

How GISAS intensity is computed

last updated 20aug25

ISimulation::simulate()
  prepareSimulation() virtual
  re_sample = ReSample::make(..)
  runSingleSimulation(re_sample, batch...)
    threaded...
      loop over i_pixel in thread
        runComputation(re_sample, i_pixel, wgt) virtual = 0

ScatteringSimulation::runComputation(re_sample, i_pixel, wgt)
  // compute intensity from scattering and specular reflection
  // multiply with beam intensity, footprint factor, and weight

Evaluate::scatteredContribution(re_sample, ele, options, polarized) -> double
  // implemented in EvaluateScattering
  sum over r: re_sample.reStructs()
    intensity += scatteringIntensity(ele, options, lambda r->scalarScattering(ele))
    // or polarized

IReStruct::scalarScattering(ele) -> double, virtual = 0

// For 2D random assemblies:
ReDisordered2D::scalarScattering(ele) -> double
  sum over w: m_cohering_subparticles
    += w->relativeAbundance() * |w->summedFF(ele)|^2

// For ordered 2D structures:
ReStructuredLayout::scalarScattering(ele) -> double
    diffuse_intensity, amplitude := 0
    loop(w: m_cohering_subparticles)
       ff = w->summedFF(ele)
       fraction = w->relativeAbundance()
       amplitude += fraction * ff
       diffuse_intensity += fraction * |ff|^2
    q := ele.meanQ()
    return diffuse_intensity + (m_iff->structureFactor(q) - 1) * |amplitude|^2

CoheringSubparticles::summedFF -> complex
  sum over s: m_unique_subparticles
    += Compute::DWBA::coherentFF(s->subparticle, s->shifts, ele)

Compute::DWBA::coherentFF(IReScatterer s, shifts, ele) -> compex
  terms = ::coherentScalarTerms(s, ele)
  sum over components and shifts
    += term.dwba_term * e^(i*q)

coherentScalarTerms(IReScatterer s, ele) -> complex
  compute ki, kf, q from ele
  compute s->theFF(q)

IReScatterer::theFF(WavevectorInfo Q) -> complex, virtual = 0

IReParticle does not override

ReParticle::theFF(Q)
  return e^(i*q) * m_ff->theFF(rotated Q)

IFormfactor::theFF(WavevectorInfo Q) -> complex
  returns formfactor(Q.getQ())

IFormfactor::formfactor(C3 q) -> complex, virtual = 0