Skip to content

Commit

Permalink
WORK IN PROGRESS
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-pereda committed May 13, 2024
1 parent 0986146 commit d2c4186
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/opengate_core/g4_bindings/chemistryadaptator.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <functional>

class G4DNAMolecularReactionTable;
#include <G4DNAMolecularReactionTable.hh>

template <typename C> class ChemistryAdaptator : public C {
public:
Expand All @@ -25,11 +26,14 @@ template <typename C> class ChemistryAdaptator : public C {

void
ConstructTimeStepModel(G4DNAMolecularReactionTable *reactionTable) override {
G4cerr << "-- ChemistryAdaptator::ConstructTimeStepModel" << G4endl;
C::ConstructTimeStepModel(reactionTable);
reactionTable->PrintTable();
}

void
ConstructReactionTable(G4DNAMolecularReactionTable *reactionTable) override {
G4cerr << "-- ChemistryAdaptator::ConstructReactionTable" << G4endl;
C::ConstructReactionTable(reactionTable);
if (_constructReactionTableHook)
_constructReactionTableHook(reactionTable);
Expand Down
4 changes: 4 additions & 0 deletions core/opengate_core/opengate_lib/GateChemistryActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void GateChemistryActor::Initialize(G4HCofThisEvent *hce) {
{
auto constructReactionTable =
[&reactions = _reactions](G4DNAMolecularReactionTable *reactionTable) {
G4cerr << "-- constructReactionTable" << G4endl;
reactionTable->Reset();

for (auto const &reaction : reactions) {
Expand All @@ -87,6 +88,7 @@ void GateChemistryActor::Initialize(G4HCofThisEvent *hce) {
reactionTable->PrintTable();
};

G4cerr << "-- add constructReactionTableHook" << G4endl;
ChemistryAdaptator<G4EmDNAChemistry_option3>::setConstructReactionTableHook(
constructReactionTable);
}
Expand All @@ -105,6 +107,7 @@ void GateChemistryActor::Initialize(G4HCofThisEvent *hce) {
void GateChemistryActor::EndSimulationAction() {}

void GateChemistryActor::EndOfRunAction(G4Run const *) {
G4cerr << "~~ DEBUG EndOfRunAction" << G4endl;
for (auto &[molecule, map] : _speciesInfoPerTime) {
for (auto &[time, data] : map) {
data.g /= _nbEvents; // mean value of g
Expand All @@ -114,6 +117,7 @@ void GateChemistryActor::EndOfRunAction(G4Run const *) {
}

void GateChemistryActor::EndOfEventAction(G4Event const *) {
G4cerr << "~~ DEBUG EndOfEventAction" << G4endl;
auto *moleculeCounter = G4MoleculeCounter::Instance();

if (not G4EventManager::GetEventManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ GateChemistryLongTimeActor::GateChemistryLongTimeActor(pybind11::dict &user_info

_doseCutOff = DictGetDouble(user_info, "dose_cutoff");

_resetScavengerForEachBeam = DictGetBool(user_info, "reset_scavenger_for_each_beam");

// TODO remove
_boundarySize = DictGetVecDouble(user_info, "boundary_size");
}
Expand All @@ -134,6 +136,8 @@ void GateChemistryLongTimeActor::Initialize(G4HCofThisEvent *hce) {
_chemistryWorld = std::make_unique<ChemistryWorld>(this);
_chemistryWorld->ConstructChemistryComponents();

G4Scheduler::Instance()->ResetScavenger(_resetScavengerForEachBeam);

G4MoleculeCounter::Instance()->SetVerbose(_moleculeCounterVerbose);
G4MoleculeCounter::Instance()->Use();
G4MoleculeCounter::Instance()->DontRegister(G4H2O::Definition());
Expand Down
2 changes: 2 additions & 0 deletions core/opengate_core/opengate_lib/GateChemistryLongTimeActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class GateChemistryLongTimeActor : public GateVActor {

double _doseCutOff = 0;

bool _resetScavengerForEachBeam = false;

// TODO remove
std::vector<double> _boundarySize;
};
Expand Down
2 changes: 2 additions & 0 deletions opengate/actors/chemistryactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def set_default_user_info(user_info):

user_info.dose_cutoff = 0

user_info.reset_scavenger_for_each_beam = False

# TODO remove
user_info.boundary_size = [0.8 * g4_units.um, 0.8 * g4_units.um, 0.8 * g4_units.um]

Expand Down
2 changes: 1 addition & 1 deletion opengate/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class PhysicsListManager(GateObject):
)

special_chemistry_constructor_classes = {}
# special_chemistry_constructor_classes["G4EmDNAChemistry_option3"] = g4.G4EmDNAChemistry_option3
special_chemistry_constructor_classes["G4EmDNAChemistry_option3"] = g4.G4EmDNAChemistry_option3

special_physics_constructor_classes["G4EmDNAChemistry"] = g4.G4EmDNAChemistry
special_physics_constructor_classes["G4EmDNAChemistry_option1"] = (
Expand Down

0 comments on commit d2c4186

Please sign in to comment.