Message: Re: How to add thermal neutron scattering to a production physics list Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Ok Re: How to add thermal neutron scattering to a production physics list 

Forum: Hadronic Processes
Re: Idea How to add thermal neutron scattering to a production physics list (Michael H. Kelsey)
Re: Question Re: How to add thermal neutron scattering to a production physics list (Karen Pease)
Date: 22 May, 2015
From: Michael H. Kelsey <Michael H. Kelsey>

On Sat, 23 May 2015 00:15:14 GMT, Karen Pease wrote:
> Thank you for taking the time to do this. First a quick note - your code
> doesn't compile, I have to add {} after " PhysicsList(G4int verbose=1) :
> FTFP_BERT_HP(verbose)" in the include file.

This is what I get for typing source code directly into Hypernews, instead of actually building an app. Okay, I have created a minimal app to exercise the code I posted, and I reproduce your failure:

> react: /home/meme/k&#65533;&#65533;i/c/klj&#65533;fur/source/src/PhysicsList.cpp:25: virtual
> void PhysicsList::ConstructProcess(): Assertion `nElastic != 0' failed.
> Aborted (core dumped)
> 
> I'm not sure exactly what this means, as I'm not sure what makes up a
> "process" in this context, but clearly FindProcess is returning null.

It means that when my code queried the "HadronicProcessStore" to get the elastic scattering process for neutrons, it found nothing.

I've dug into the toolkit code, and I find that the HadronicProcessStore doesn't get filled until the "PreparePhysicsTable" action is invoked by the run manager. This doesn't happen until after the physics list's ConstructProcess() function is completed. So the code I wrote can't work the way I designed it, because the table of hadronic processes is empty at the time I try to use it. Sigh....

I had based this code on something I'm already doing in my own application (I have to modify the processes attached to G4Triton, in order to get proper tritium decays). I wanted to use the HadronicProcessStore because it would be more efficient than looping over the processes attached to the neutron. Silly me.

Here's a version equivalent to what I did in my own app. This is just the ConstructProcess() function; the rest of what you did is correct:

#include "G4HadronicInteractionRegistry.hh"
#include "G4HadronicProcess.hh"
#include "G4HadronicProcessType.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4Neutron.hh"
#include "G4NeutronHPThermalScattering.hh"
#include "G4NeutronHPThermalScatteringData.hh"
#include <assert.h>

void TSPhysicsList::ConstructProcess() {
  G4VModularPhysicsList::ConstructProcess();

  // Get the elastic scattering process for neutrons
  G4ParticleDefinition* nPD = G4Neutron::Definition();

  G4ProcessVector* pvec = nPD->GetProcessManager()->GetProcessList();
  G4HadronicProcess* nElastic = 0;
  for (G4int i=0; i<pvec->size(); i++) {
    if ((*pvec)[i]->GetProcessSubType() != fHadronElastic) continue;
    nElastic = dynamic_cast<G4HadronicProcess*>((*pvec)[i]);
    break;
  }
  assert(nElastic != 0);

  // Get the "regular" HP elastic scattering model, exclude thermal scattering region
  G4HadronicInteraction* nElasticHP = G4HadronicInteractionRegistry::Instance()->FindModel("NeutronHPElastic");
  assert(nElasticHP != 0);
  nElasticHP->SetMinEnergy(4.*eV);

  // Attach HP thermal scattering model and data files to process
  nElastic->RegisterMe(new G4NeutronHPThermalScattering);
  nElastic->AddDataSet(new G4NeutronHPThermalScatteringData);
}

I ran my test app, and got no assertions. At beamOn, in addition to the usual silly messages from NeutronHP, I got:

  Neutron HP Thermal Scattering Data: Following material-element pairs and/or elements are registered.

So that's maybe a good sign.

  -- Michael Kelsey

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Sad: Re: How to add thermal neutron scattering to a production physics list   (Karen Pease - 23 May, 2015)
2 None: Re: How to add thermal neutron scattering to a production physics list   (Karen Pease - 23 May, 2015)
 Add Message Add Message
to: "Re: How to add thermal neutron scattering to a production physics list"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]