Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geant4 v11 update #924

Merged
merged 33 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2bf5f31
find geant4 manual mode
ahnaf-tahmid-chowdhury Sep 18, 2023
2b1fc23
remove moab condition
ahnaf-tahmid-chowdhury Sep 18, 2023
0c4a183
remove moab version condition
ahnaf-tahmid-chowdhury Sep 18, 2023
8a6af96
rearrange logger, then require_density
ahnaf-tahmid-chowdhury Sep 18, 2023
c162950
remove moab conditions
ahnaf-tahmid-chowdhury Sep 18, 2023
47cd28b
new condition Geant4_VERSION GREATER_EQUAL 11.0
ahnaf-tahmid-chowdhury Sep 18, 2023
71a1763
removed itaps and added PyNE's dagmc by @gonuke
ahnaf-tahmid-chowdhury Sep 18, 2023
627be18
GEANT4_GT_11
ahnaf-tahmid-chowdhury Sep 18, 2023
0e17740
GEANT4_GT_11
ahnaf-tahmid-chowdhury Sep 18, 2023
55292f7
GEANT4_GT_10_6 uill use MeshScoreMap
ahnaf-tahmid-chowdhury Sep 18, 2023
a1d0362
geant4 v11 support
ahnaf-tahmid-chowdhury Sep 18, 2023
0f5239d
Patch to compile with Geant4 11.x
ahnaf-tahmid-chowdhury Sep 18, 2023
f7c4acf
Geant4ConfigVersion
ahnaf-tahmid-chowdhury Sep 19, 2023
4c0302e
find a volume in a DAGMC instance if moab >5.2
ahnaf-tahmid-chowdhury Oct 2, 2023
5737e45
geant4 11.1.2 added
ahnaf-tahmid-chowdhury Oct 2, 2023
968f6f7
geant4_version=11.1.2
ahnaf-tahmid-chowdhury Oct 2, 2023
6d8c89d
follow dagmc format
ahnaf-tahmid-chowdhury Oct 19, 2023
8f583c6
add const
ahnaf-tahmid-chowdhury Oct 19, 2023
8ce9f3b
add const
ahnaf-tahmid-chowdhury Oct 19, 2023
61f28e5
soft reset
ahnaf-tahmid-chowdhury Oct 19, 2023
0769e84
geant4 11.1.2
ahnaf-tahmid-chowdhury Oct 19, 2023
b4b5a7d
sefault geant4 11.1.2
ahnaf-tahmid-chowdhury Oct 20, 2023
fc1507c
new stage geant4
ahnaf-tahmid-chowdhury Oct 20, 2023
510445f
add 11.1.2 geant4
ahnaf-tahmid-chowdhury Oct 20, 2023
928b9f0
geant4 11.1.2
ahnaf-tahmid-chowdhury Oct 20, 2023
ee0b75b
soft reset
ahnaf-tahmid-chowdhury Oct 20, 2023
42b98d3
Merge branch 'svalinn:develop' into fix-geant4-build
ahnaf-tahmid-chowdhury Oct 22, 2023
c0fc92c
Update cmake/FindGeant4.cmake
ahnaf-tahmid-chowdhury Nov 30, 2023
fa54fff
find path for geant4 11+
ahnaf-tahmid-chowdhury Nov 30, 2023
6b761f1
remove build test until we have a working docker container
gonuke Nov 30, 2023
4ec7aa6
remove explicit gcc install in mac_build_test.yml
gonuke Dec 1, 2023
1f137ff
address review comments
gonuke Dec 7, 2023
b1e0091
random typo
gonuke Dec 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/upstream-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
geant_version:
description: Version of Geant4
required: false
default: 10.7.4
default: 11.1.2
ubuntu_version:
description: Underlying OS version
required: false
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
]
geant_version : [
10.7.4,
11.1.2
]

name: Installing Dependencies, Building DAGMC and running tests
Expand Down Expand Up @@ -94,6 +95,7 @@ jobs:
]
geant_version : [
10.7.4,
11.1.2
]

name: Pushing final images
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux_upstream_test_geant4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
uses: ./.github/actions/upstream-test
with:
token: ${{ secrets.GITHUB_TOKEN }}
geant_version: 11.1.1
geant_version: 11.1.2

2 changes: 1 addition & 1 deletion .github/workflows/mac_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Initial setup
shell: bash -l {0}
run: |
brew install eigen gcc@6 hdf5
brew install eigen hdf5
pshriwise marked this conversation as resolved.
Show resolved Hide resolved

- name: Environment Variables
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion CI/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Global ARGS set before the first build stage are accessable by all build stages
ARG EMBREE_BRANCH='v3.6.1'
ARG geant4_version=10.7.4
ARG geant4_version=11.1.2
ARG UBUNTU_VERSION=20.04
ARG MOAB_BRANCH=5.3.0
ARG double_down=OFF
Expand Down
21 changes: 11 additions & 10 deletions cmake/FindGeant4.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Find Geant4 cmake config file
set(Geant4_SEARCH_DIRS)
# Is this line necessary?
set(PACKAGE_FIND_VERSION ${Geant4_FIND_VERSION})
file(GLOB Geant4_SEARCH_DIRS "${GEANT4_DIR}/lib*/Geant4-*")

file(GLOB Geant4_SEARCH_DIRS "${GEANT4_DIR}/lib*/Geant4*")
string(REPLACE "\n" ";" Geant4_SEARCH_DIRS ${Geant4_SEARCH_DIRS})
list(APPEND Geant4_SEARCH_DIRS "${GEANT4_DIR}/lib/cmake/Geant4")

find_path(Geant4_CMAKE_CONFIG
NAMES Geant4Config.cmake
PATHS ${Geant4_SEARCH_DIRS}
NO_DEFAULT_PATH
)

find_path(Geant4_CMAKE_CONFIG_VERSION
NAMES Geant4ConfigVersion.cmake
PATHS ${Geant4_SEARCH_DIRS}
PATHS ${Geant4_CMAKE_CONFIG}
NO_DEFAULT_PATH
)

Expand All @@ -21,11 +27,6 @@ else ()
message(FATAL_ERROR "Could not find Geant4")
endif ()

find_path(Geant4_CMAKE_CONFIG
NAMES Geant4Config.cmake
PATHS ${Geant4_SEARCH_DIRS}
NO_DEFAULT_PATH
)
if (Geant4_CMAKE_CONFIG)
set(Geant4_CMAKE_CONFIG ${Geant4_CMAKE_CONFIG}/Geant4Config.cmake)
message(STATUS "Geant4_CMAKE_CONFIG: ${Geant4_CMAKE_CONFIG}")
Expand Down Expand Up @@ -58,7 +59,7 @@ include(${Geant4_USE_FILE})
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_SAVE})

message(STATUS "Geant4 version: ${Geant4_VERSION}")
message(STATUS "Geant4 version required: ${PACKAGE_FIND_VERSION}")
message(STATUS "Geant4 version required: ${Geant4_FIND_VERSION}")
message(STATUS "Geant4 version compatible: ${PACKAGE_VERSION_COMPATIBLE}")
message(STATUS "Geant4 version exact: ${PACKAGE_VERSION_EXACT}")
message(STATUS "Geant4_INCLUDE_DIRS: ${Geant4_INCLUDE_DIRS}")
Expand Down
2 changes: 1 addition & 1 deletion doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Next version
* Adding const identifier to cross-reference methods (#906)

**Fixed:**
* Patch to compile with Geant4 10.6 (#803)
* Patch to compile with Geant4 11.x (#803 #907)
* Patched cmake-search paths for double-down and MOAB (#878)
* Patch to compile with gcc-13 (#882)
* Tweak conda environment for Windows build to avoid conflicting gtest headers (#888)
Expand Down
6 changes: 5 additions & 1 deletion src/geant4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ message("")

find_package(Geant4 10.4.2 REQUIRED)

if ( Geant4_VERSION GREATER_EQUAL 10.6 )
if ( Geant4_VERSION GREATER_EQUAL 11.0 )
message(STATUS "Configuring DAGMC for Geant4 version >= 11.0")
add_compile_definitions(GEANT4_GT_10_6=1)
add_compile_definitions(GEANT4_GT_11=1)
elseif( Geant4_VERSION GREATER_EQUAL 10.6 )
message(STATUS "Configuring DAGMC for Geant4 version >= 10.6")
add_compile_definitions(GEANT4_GT_10_6=1)
endif()
Expand Down
4 changes: 4 additions & 0 deletions src/geant4/app/include/ExN01Analysis.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#ifndef ExN01Analysis_h
#define ExN01Analysis_h 1

#ifdef GEANT4_GT_11
#include "G4AnalysisManager.hh"
#else
#include "g4root.hh"
#endif

#endif
5 changes: 4 additions & 1 deletion src/geant4/app/src/ExN01DetectorConstruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ G4VPhysicalVolume* ExN01DetectorConstruction::Construct() {
// load the material from the UW^2 library
std::map<std::string, G4Material*> material_lib;
material_lib = load_uwuw_materials(workflow_data);

#ifdef GEANT4_GT_11
G4VisAttributes* invis = new G4VisAttributes(G4VisAttributes::GetInvisible());
#else
G4VisAttributes* invis = new G4VisAttributes(G4VisAttributes::Invisible);
#endif

//------------------------------------------------------ volumes
// -- World Volume in which we place other volumes
Expand Down
6 changes: 5 additions & 1 deletion src/geant4/app/src/ExN01UserScoreWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ void ExN01UserScoreWriter::DumpAllQuantitiesToFile(const G4String& fileName,
G4cout << "Dumping mesh " << fScoringMesh->GetWorldName() << " to file"
<< G4endl;

// retrieve the map
// retrieve the map
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are also just above. We should only need this once. Might be a change inherited from the original PR.

#ifdef GEANT4_GT_10_6
using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
#endif

MeshScoreMap scMap = fScoringMesh->GetScoreMap();

// get the number of bins
Expand Down
83 changes: 18 additions & 65 deletions src/geant4/generate_geant4
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

from optparse import OptionParser
import os,errno
from itaps import iMesh,iBase
import sys
# for material handling
from pyne.material import Material,MaterialLibrary
from pyne.material import Material
from pyne.material_library import MaterialLibrary
from pyne.nucname import name, znum, anum, id, alara
from pyne.data import atomic_mass
from pyne import dagmc

# for coloring the volumes
import colorsys
Expand Down Expand Up @@ -70,7 +72,7 @@ def parse_arguments():
try:
fh = open(options.dag_file, "r")
except IOError:
print "Error: can\'t find DAG file"
print("Error: can't find DAG file")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Error: can't find DAG file")
print("Error: can't find DAG file: '{}' ".format(options.dag_file))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid the extra else block at the end:

try:
    fh = open(options.dag_file, 'r')
    fh.close()
except IOError:
    print("Error: can't find DAG file: '{}'".format(options.dag_file))

else:
fh.close()
if not options.directory:
Expand All @@ -90,69 +92,17 @@ dag_filename : h5m filename

Returns
---------
dag_volnames : dictionary of volume names

dag_vol_names : list of volume names
dag_materials : dictionary of material assignments
"""

def _get_dag_info(dag_filename):
dag_vol_names = [] # list of dag volume names (Cubit id)
dag_materials = {} # list of material assignments from group

# create imesh instance
dag_geom = iMesh.Mesh()
# load the file
dag_geom.load(dag_filename)

# get all entities
ents = dag_geom.getEntities()

# create a mesh set
mesh_set = dag_geom.getEntSets()
# list of volume ent handles

mat_list = []
# get all geom_dimension ents
geom_list = []

cat_list = []

vol_tag = dag_geom.getTagHandle('GEOM_DIMENSION')

name_tag = dag_geom.getTagHandle('GLOBAL_ID')
dag_materials = dagmc.cell_material_assignments(dag_filename)

mat_tag = dag_geom.getTagHandle('NAME')
dag_vol_names = [dag_materials.keys()]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dag_vol_names = [dag_materials.keys()]
dag_vol_names = list(dag_materials.keys())


cat_tag = dag_geom.getTagHandle('CATEGORY')

# get the list we need
for i in mesh_set:
tags = dag_geom.getAllTags(i)
for tag in tags:
if tag == vol_tag:
geom_list.append(i)
if tag == mat_tag:
mat_list.append(i)
if tag == cat_tag:
cat_list.append(i)

# for the 3d entities
for entity in geom_list:
if vol_tag[entity] == 3:
dag_vol_names.append(str(name_tag[entity]))


# loop over all the volumes
for entity in geom_list:
# loop over the material sets
for meshset in mat_list:
# if volume in set
if meshset.contains(entity):
mat_name = mat_tag[meshset]
volume_name = name_tag[entity]
dag_materials[volume_name]="".join( chr( val ) for val in mat_name )


return dag_vol_names,dag_materials
return dag_vol_names, dag_materials

"""
Function to pull out the pyne materials from the h5m file
Expand All @@ -179,8 +129,8 @@ def _get_material_info(dag_file):
mat_lib.from_hdf5(dag_file)
materials = mat_lib.keys()
except:
print "!! There are no materials in the h5m file !!"
print " Assuming all volumes contain vacuum "
print("There are no materials in the h5m file!!")
print("Assuming all volumes contain vacuum")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("There are no materials in the h5m file!!")
print("Assuming all volumes contain vacuum")
print("There are no materials in the h5m file.\n "
"Assuming all volumes contain vacuum")

materials = {}

nuclides = set()
Expand Down Expand Up @@ -534,7 +484,7 @@ dag_volume_names : list or dictionary of volume names
def _setup_dagspecific_headers(dag_volume_names, tallies_needed):

if not dag_volume_names:
print "dag volume names not assigned", sys.exc_info()[0]
print("dag volume names not assigned", sys.exc_info()[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("dag volume names not assigned", sys.exc_info()[0])
print("DAGMC volume names are not assigned", sys.exc_info()[0])

raise

headers = {}
Expand Down Expand Up @@ -1680,7 +1630,7 @@ def _write_files(path, dictionary_files):
try:
fh = open(path+'/'+key, "w")
except IOError:
print "Error: "+file+" file exists"
print("Error: "+key+" file exists")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Error: "+key+" file exists")
print("Error: {} file exists".format(key))

else:
for line in dictionary_files[key]:
fh.write(line)
Expand All @@ -1707,9 +1657,12 @@ def _create_directory_structure(directory):
_mkdir_p(directory+'/src')
return

# Fix: Don't know what it does
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to remove this function?

def _dagmc_volume_material(dagmc_h5m, index):

return material_name
"""

"""
Function from http://stackoverflow.com/questions
Expand All @@ -1724,7 +1677,7 @@ def _mkdir_p(path):
try:
os.makedirs(path)
except OSError:
print "Error: can\'t create directory, "+path
print("Error: can't create directory, "+path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("Error: can't create directory, "+path)
print("Error: can't create directory '{}' ".format(path))

raise


Expand Down