Skip to content

Commit

Permalink
updated to most recent wv, g4 working well
Browse files Browse the repository at this point in the history
  • Loading branch information
makeclean committed Sep 28, 2014
1 parent 5786c76 commit b1d8fb4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
5 changes: 4 additions & 1 deletion geant4/build/exampleN01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ int main(int argc, char* argv[])
//
runManager->Initialize();

/*
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();

Expand All @@ -75,10 +76,12 @@ int main(int argc, char* argv[])
UImanager->ApplyCommand("/run/verbose 1");
UImanager->ApplyCommand("/event/verbose 1");
UImanager->ApplyCommand("/tracking/verbose 1");
*/


// Start a run
//
G4int numberOfEvent = 3;
G4int numberOfEvent = 1e6;
runManager->BeamOn(numberOfEvent);

// Job termination
Expand Down
20 changes: 14 additions & 6 deletions geant4/build/src/ExN01DetectorConstruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
using namespace moab;

// dag_volumes
std::vector<G4LogicalVolume*> dag_logical_volumes;
std::map<int, G4LogicalVolume*> dag_logical_volumes;


DagMC* dagmc = DagMC::instance(); // create dag instance
Expand Down Expand Up @@ -144,7 +144,8 @@ G4VPhysicalVolume* ExN01DetectorConstruction::Construct()
"vol_"+idx_str+"_log",0,0,0);

std::cout << "vol_" << idx_str << " has prop " << material_lib["mat:"+dag_material_name] << std::endl;
dag_logical_volumes.push_back(dag_vol_log);
// dag_logical_volumes.push_back(dag_vol_log);
dag_logical_volumes[dag_idx]=dag_vol_log;

// define physical volumes
G4PVPlacement* dag_vol_phys = new G4PVPlacement(0,G4ThreeVector(0*cm,0*cm,0*cm),dag_vol_log,
Expand Down Expand Up @@ -209,17 +210,19 @@ void ExN01DetectorConstruction::ConstructSDandField()
MBEntityHandle vol = dagmc->entity_by_id(3,vol_id); // convert id to eh
int vol_idx = dagmc->index_by_handle(vol); // get the volume index

particles = volume_part_map[vol_idx];
particles = volume_part_map[vol_id];
particles.push_back(scorer.particle_name);
volume_part_map[vol_idx] = particles;
volume_part_map[vol_id] = particles;

// build the filters
/*
if( 0 < particle_filters.count(scorer.particle_name))
{
G4SDParticleFilter *filter = new G4SDParticleFilter(scorer.particle_name);
filter->add(pyne::particle::geant4(scorer.particle_name));
particle_filters[scorer.particle_name]=filter;
}
*/
}
}

Expand All @@ -230,7 +233,7 @@ void ExN01DetectorConstruction::ConstructSDandField()
std::vector<std::string>::iterator str;
for ( str = (it->second).begin() ; str != (it->second).end() ; ++str )
{
std::cout << (*str) << std::endl;
std::cout << (it->first) << " " << (*str) << std::endl;
}
}

Expand All @@ -239,19 +242,24 @@ void ExN01DetectorConstruction::ConstructSDandField()
for ( it = volume_part_map.begin() ; it != volume_part_map.end() ; ++it )
{
// turn the idx into string
std::cout << (it->first) << std::endl;
std::stringstream int_to_string;
int_to_string << (it->first);
std::string idx_str = int_to_string.str();

// create new detector
G4MultiFunctionalDetector *detector = new G4MultiFunctionalDetector("vol_"+idx_str+"_flux");
G4SDManager::GetSDMpointer()->AddNewDetector(detector);
dag_logical_volumes[it->first]->SetSensitiveDetector(detector);

MBEntityHandle vol = dagmc->entity_by_id(3,it->first); // convert id to eh
int vol_idx = dagmc->index_by_handle(vol); // get the volume index
dag_logical_volumes[vol_idx]->SetSensitiveDetector(detector);

// loop over the vector of particle types
std::vector<std::string>::iterator str;
for ( str = (it->second).begin() ; str != (it->second).end() ; ++str )
{
std::cout << *str << std::endl;
// set the sensitivity
G4VPrimitiveScorer *particle_flux = new G4PSCellFlux(*str+"CellFlux");
// particle_flux->SetFilter(particle_filters[*str]);
Expand Down
8 changes: 4 additions & 4 deletions geant4/build/src/ExN01PrimaryGeneratorAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ void ExN01PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
//G4double y = 1.0*(G4UniformRand()-0.5);
// G4double z = 1.0*(G4UniformRand()-0.5);
// particleGun->SetParticlePosition(G4ThreeVector(1.24*cm,1.24*cm,100.0*cm));
particleGun->SetParticlePosition(G4ThreeVector(-50.*cm,0.*cm,0.*cm));
particleGun->SetParticleMomentumDirection(G4ThreeVector(1.0,0.0,0.0));
particleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,0.*cm));
// particleGun->SetParticleMomentumDirection(G4ThreeVector(1.0,0.0,0.0));

// particleGun->SetParticlePosition(G4ThreeVector(-10.0*cm,y*cm,z*cm));
// G4int i = anEvent->GetEventID() % 3;

/*

G4double cosTheta = 2*G4UniformRand() - 1.;
G4double phi = twopi*G4UniformRand();
G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
G4double ux = sinTheta*std::cos(phi),
uy = sinTheta*std::sin(phi),
uz = cosTheta;
particleGun->SetParticleMomentumDirection(G4ThreeVector(ux,uy,uz));
*/

particleGun->GeneratePrimaryVertex(anEvent);
}

Expand Down
6 changes: 3 additions & 3 deletions geant4/build/src/ExN01RunAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ExN01RunAction::ExN01RunAction(UWUW data)

std::string tally_name = ss.str()+"/"+(it->second).tally_type+"/"+(it->second).particle_name;
// create historgram
analysisManager->CreateH1(tally_name,(it->second).tally_name,100,0.,1.*m);
analysisManager->CreateH1(tally_name,(it->second).tally_name,100,0.,10.);
// create tuple
analysisManager->CreateNtupleDColumn(tally_name);
}
Expand Down Expand Up @@ -118,8 +118,8 @@ void ExN01RunAction::EndOfRunAction(const G4Run* /*run*/)
<< " rms = " << G4BestUnit(analysisManager->GetH1(index)->rms(), "Length") << G4endl;
*/

G4cout << tally_name+" : mean = " << analysisManager->GetH1(index)->mean()/(mm*mm)
<< " rms = " << analysisManager->GetH1(index)->rms()/(mm*mm) << G4endl;
G4cout << tally_name+" : mean = " << analysisManager->GetH1(index)->mean()*cm*cm
<< " rms = " << analysisManager->GetH1(index)->rms()*cm*cm << G4endl;

}
}
Expand Down
6 changes: 3 additions & 3 deletions mcnp5/mcnp_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,13 @@ void write_lcad_uwuw(std::ofstream &lcadfile, UWUW workflow_data)
pyne::Material material;

double density;
std::string material_number;
int material_number;

// loop over all cells
for( int i = 1; i <= num_cells; ++i ) {

density = 0.0;
material_number = "";
material_number = 0;

int cellid = DAG->id_by_index( 3, i );
MBEntityHandle entity = DAG->entity_by_index( 3, i );
Expand Down Expand Up @@ -375,7 +375,7 @@ void write_lcad_uwuw(std::ofstream &lcadfile, UWUW workflow_data)
&& !(DAG->is_implicit_complement(entity)) )
{
material = material_library[grp_name];
material_number = material.metadata["mat_number"].asString();
material_number = material.metadata["mat_number"].asInt();
density = -1.0*material.density; // -ve for mass density
lcadfile << cellid << " " << material_number << " " << density << " imp:n=1" << std::endl;
}
Expand Down
9 changes: 3 additions & 6 deletions uwuw/uwuw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ std::map<std::string, pyne::Material> UWUW::load_pyne_materials(std::string file
}
else
{
std::string result;
std::ostringstream matnum; // stream used for the conversion
matnum << i+1; // insert the textual representation of 'Number' in the characters in the streamng
mat.metadata["mat_number"]=matnum.str();

// renumber material number by position in the library
mat.metadata["mat_number"]=i+1;
library[mat.metadata["name"].asString()]=mat;
}
}
Expand All @@ -103,7 +100,7 @@ std::map<std::string, pyne::Material> UWUW::load_pyne_materials(std::string file
return library;
}

// loads all materials into map
// loads all tallies into map
std::map<std::string, pyne::Tally> UWUW::load_pyne_tallies(std::string filename)
{
std::map<std::string, pyne::Tally> library; // material library
Expand Down

0 comments on commit b1d8fb4

Please sign in to comment.