Skip to content

Commit 6cdfcc1

Browse files
petercampsKoseimatsu
authored andcommitted
Make instruments record fluorescence as secondary emission (SKIRT#256)
* detect emulation in configuration * add no-op scattering to base class * honor emulation in medium system * honor emulation in instruments * store rf according to phase
1 parent 19a252a commit 6cdfcc1

28 files changed

Lines changed: 116 additions & 95 deletions

SKIRT/core/Configuration.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "MaterialMix.hpp"
1212
#include "MaterialWavelengthRangeInterface.hpp"
1313
#include "MonteCarloSimulation.hpp"
14-
#include "NR.hpp"
1514
#include "OligoWavelengthDistribution.hpp"
1615
#include "OligoWavelengthGrid.hpp"
1716
#include "ProbeSystem.hpp"
@@ -325,9 +324,13 @@ void Configuration::setupSelfBefore()
325324
_hasSingleConstantSectionMedium = numMedia == 1 && _hasConstantSectionMedium;
326325
_hasMultipleConstantSectionMedia = numMedia > 1 && _hasConstantSectionMedium;
327326

328-
// check for scattering dispersion
327+
// check for scattering dispersion and for emulating secondary emission
329328
for (auto medium : ms->media())
329+
{
330330
if (medium->mix()->hasScatteringDispersion()) _hasScatteringDispersion = true;
331+
if (medium->mix()->scatteringEmulatesSecondaryEmission()) _scatteringEmulatesSecondaryEmission = true;
332+
}
333+
_needIndividualPeelOff = _hasScatteringDispersion | _scatteringEmulatesSecondaryEmission;
331334

332335
// check for magnetic fields
333336
for (int h = 0; h != numMedia; ++h)

SKIRT/core/Configuration.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,13 @@ class Configuration : public SimulationItem
209209
weight factors. */
210210
bool hasMultipleConstantSectionMedia() const { return _hasMultipleConstantSectionMedia; }
211211

212+
/** Returns true if a scattering interaction for one or more media may emulate secondary
213+
emission, and false otherwise. */
214+
bool scatteringEmulatesSecondaryEmission() const { return _scatteringEmulatesSecondaryEmission; }
215+
212216
/** Returns true if a scattering interaction for one or more media may adjust the wavelength of
213-
the interacting photon packet, and false otherwise. */
214-
bool hasScatteringDispersion() const { return _hasScatteringDispersion; }
217+
the interacting photon packet or may emulate secondary emission, and false otherwise. */
218+
bool needIndividualPeelOff() const { return _needIndividualPeelOff; }
215219

216220
/** Returns true if all media in the simulation support polarization, and false if none of the
217221
media do. A mixture of support and no support for polarization is not allowed and will
@@ -467,6 +471,8 @@ class Configuration : public SimulationItem
467471
bool _hasSingleConstantSectionMedium{false};
468472
bool _hasMultipleConstantSectionMedia{false};
469473
bool _hasScatteringDispersion{false};
474+
bool _scatteringEmulatesSecondaryEmission{false};
475+
bool _needIndividualPeelOff{false};
470476
bool _hasPolarization{false};
471477
bool _hasSpheroidalPolarization{false};
472478

SKIRT/core/DustMix.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ namespace
427427

428428
////////////////////////////////////////////////////////////////////
429429

430-
void DustMix::peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs,
430+
bool DustMix::peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs,
431431
Direction bfky, const MaterialState* /*state*/, const PhotonPacket* pp) const
432432
{
433433
switch (scatteringMode())
@@ -482,6 +482,7 @@ void DustMix::peeloffScattering(double& I, double& Q, double& U, double& V, doub
482482
break;
483483
}
484484
}
485+
return false;
485486
}
486487

487488
////////////////////////////////////////////////////////////////////

SKIRT/core/DustMix.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class DustMix : public MaterialMix
277277
plane, applies the Mueller matrix on the Stokes vector, and further rotates the Stokes
278278
vector from the reference direction in the peel-off scattering plane to the x-axis of the
279279
instrument to which the peel-off photon packet is headed. */
280-
void peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs, Direction bfky,
280+
bool peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs, Direction bfky,
281281
const MaterialState* state, const PhotonPacket* pp) const override;
282282

283283
/** This function performs a scattering event on the specified photon packet in the spatial

SKIRT/core/ElectronMix.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ namespace
171171

172172
////////////////////////////////////////////////////////////////////
173173

174-
void ElectronMix::peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs,
174+
bool ElectronMix::peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs,
175175
Direction bfky, const MaterialState* state, const PhotonPacket* pp) const
176176
{
177177
// if we have dispersion, adjust the incoming wavelength to the electron rest frame
@@ -197,6 +197,7 @@ void ElectronMix::peeloffScattering(double& I, double& Q, double& U, double& V,
197197
{
198198
lambda = PhotonPacket::shiftedEmissionWavelength(lambda, bfkobs, scatinfo->velocity);
199199
}
200+
return false;
200201
}
201202

202203
////////////////////////////////////////////////////////////////////

SKIRT/core/ElectronMix.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class ElectronMix : public MaterialMix
170170
171171
If \em includePolarization has been set to true, the function supports polarization;
172172
otherwise it does not. */
173-
void peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs, Direction bfky,
173+
bool peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs, Direction bfky,
174174
const MaterialState* state, const PhotonPacket* pp) const override;
175175

176176
/** This function performs a scattering event on the specified photon packet in the spatial

SKIRT/core/FragmentDustMixDecorator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ double FragmentDustMixDecorator::opacityExt(double lambda, const MaterialState*
213213

214214
////////////////////////////////////////////////////////////////////
215215

216-
void FragmentDustMixDecorator::peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda,
216+
bool FragmentDustMixDecorator::peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda,
217217
Direction bfkobs, Direction bfky, const MaterialState* state,
218218
const PhotonPacket* pp) const
219219
{
@@ -240,6 +240,7 @@ void FragmentDustMixDecorator::peeloffScattering(double& I, double& Q, double& U
240240
V += Vf * wf;
241241
}
242242
}
243+
return false;
243244
}
244245

245246
////////////////////////////////////////////////////////////////////

SKIRT/core/FragmentDustMixDecorator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class FragmentDustMixDecorator : public MaterialMix, public MultiGrainPopulation
184184
the fragment. The contributions to the Stokes vector components are stored in the \em I,
185185
\em Q, \em U, \em V arguments, which are guaranteed to be initialized to zero by the
186186
caller. For dust mixes, the wavelength remains unchanged. */
187-
void peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs, Direction bfky,
187+
bool peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda, Direction bfkobs, Direction bfky,
188188
const MaterialState* state, const PhotonPacket* pp) const override;
189189

190190
/** This function performs a scattering event on the specified photon packet in the spatial

SKIRT/core/Instrument.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "Instrument.hpp"
77
#include "Configuration.hpp"
8-
#include "FatalError.hpp"
98
#include "FluxRecorder.hpp"
109

1110
////////////////////////////////////////////////////////////////////
@@ -20,7 +19,7 @@ void Instrument::setupSelfBefore()
2019

2120
// discover details about the simulation
2221
bool hasMedium = config->hasMedium();
23-
bool hasMediumEmission = config->hasSecondaryEmission();
22+
bool hasMediumEmission = config->hasSecondaryEmission() || config->scatteringEmulatesSecondaryEmission();
2423

2524
// partially configure the flux recorder
2625
_recorder = new FluxRecorder(this);

SKIRT/core/LyaNeutralHydrogenGasMix.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ double LyaNeutralHydrogenGasMix::opacityExt(double lambda, const MaterialState*
132132

133133
////////////////////////////////////////////////////////////////////
134134

135-
void LyaNeutralHydrogenGasMix::peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda,
135+
bool LyaNeutralHydrogenGasMix::peeloffScattering(double& I, double& Q, double& U, double& V, double& lambda,
136136
Direction bfkobs, Direction bfky, const MaterialState* state,
137137
const PhotonPacket* pp) const
138138
{
@@ -159,6 +159,8 @@ void LyaNeutralHydrogenGasMix::peeloffScattering(double& I, double& Q, double& U
159159

160160
// Doppler-shift the photon packet wavelength into and out of the atom frame
161161
lambda = LyaUtils::shiftWavelength(lambda, scatinfo->velocity, pp->direction(), bfkobs);
162+
163+
return false;
162164
}
163165

164166
////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)