Skip to content

Commit

Permalink
Merge pull request #1 from pyne/develop
Browse files Browse the repository at this point in the history
Update from pnye/develop
  • Loading branch information
gwenchee authored Feb 23, 2018
2 parents 1e9611c + e0f7272 commit 646ba5c
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 165 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ project(pyne)
include(PyneMacros)
pyne_print_logo() # Beware of dragons
pyne_set_platform()
pyne_set_asm_platform()
pyne_set_build_spatial_solver()
pyne_set_build_type()
pyne_set_fast_compile()
Expand Down
38 changes: 38 additions & 0 deletions cmake/DownloadAndExtract.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Macros for downloading a tar file and extracting it if a sample file
# doesn't already exist.

macro(download_and_extract _url _checkfile)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_checkfile}")
# don't need to do anything
message(STATUS "${_checkfile} exists, no need to download or extract!")
else()
get_filename_component(_base "${_url}" NAME)
# download the file if we need to
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_base}")
message(STATUS "Downloading ${_url} -> ${_base}")
file(DOWNLOAD "${_url}" "${CMAKE_CURRENT_SOURCE_DIR}/${_base}"
SHOW_PROGRESS STATUS _rtn TLS_VERIFY OFF)
list(GET _rtn 0 _rtncode)
if(NOT 0 EQUAL _rtncode)
message(FATAL_ERROR ${_rtn})
endif()
endif()
# extract the file
message(STATUS "Extracting ${_base}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf "${_base}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
endmacro()


macro(download_platform _base_url _base_name _ext_src _ext_plat)
# first download the src file
set(_url "${_base_url}/${_base_name}.tar.gz")
set(_checkfile "${_base_name}${_ext_src}")
download_and_extract("${_url}" "${_checkfile}")
# now download the platform specific file
set(_url "${_base_url}/${_base_name}-${PYNE_ASM_PLATFORM}.tar.gz")
set(_checkfile "${_base_name}-${PYNE_ASM_PLATFORM}${_ext_plat}")
download_and_extract("${_url}" "${_checkfile}")
endmacro()

41 changes: 36 additions & 5 deletions cmake/PyneMacros.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
INCLUDE(DownloadAndExtract)

# set platform preprocessor macro
macro(pyne_set_platform)
set(PYNE_PLATFORM "__${CMAKE_SYSTEM_NAME}__")
Expand All @@ -16,6 +18,28 @@ macro(pyne_set_platform)
message("-- Pyne platform defined as: ${PYNE_PLATFORM}")
endmacro()

macro(pyne_set_asm_platform)
# first set OS
if (WIN32)
set(_plat "win")
elseif(APPLE)
set(_plat "apple")
else()
set(_plat "linux")
endif()
# next set compiler
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(_plat "${_plat}-gnu")
elseif (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"))
set(_plat "${_plat}-clang")
else()
set(_plat "${_plat}-NOTFOUND")
endif()
set(PYNE_ASM_PLATFORM "${_plat}")
endmacro()


# Fortran settings
# FFLAGS depend on the compiler
macro(pyne_setup_fortran)
Expand Down Expand Up @@ -169,6 +193,15 @@ macro(pyne_configure_rpath)
MESSAGE("-- CMAKE_INSTALL_RPATH: ${CMAKE_INSTALL_RPATH}")
endmacro()

macro(pyne_download_platform)
# Download bateman solver from PyNE data
download_platform("https://raw.githubusercontent.com/pyne/data/master" "decay"
".cpp" ".s")

# Download CRAM solver from PyNE data
download_platform("http://raw.githubusercontent.com/pyne/data/master" "cram"
".c" ".s")
endmacro()

macro(pyne_set_fast_compile)
if(NOT DEFINED PYNE_FAST_COMPILE)
Expand All @@ -182,10 +215,8 @@ endmacro()
macro(fast_compile _srcname _gnuflags _clangflags _otherflags)
get_filename_component(_base "${_srcname}" NAME_WE) # get the base name, without the extension
# get the assembly file name
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(_asmname "${_base}-clang.s")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(_asmname "${_base}-gnu.s")
if (PYNE_ASM_PLATFORM)
set(_asmname "${_base}-${PYNE_ASM_PLATFORM}.s")
else()
set(_asmname "${_base}-NOTFOUND")
endif()
Expand All @@ -201,7 +232,7 @@ macro(fast_compile _srcname _gnuflags _clangflags _otherflags)
message(STATUS "Compiling ${_srcname} fast from assembly ${_asmname}")
set(_filename "${_asmname}")
endif()
set(PYNE_SRCS "${PYNE_SRCS}" "${_filename}")
set(PYNE_SRCS "${_filename}" "${PYNE_SRCS}")

# set some compile flags for the selected file
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand Down
12 changes: 12 additions & 0 deletions news/Tag_shape_remove_unused_code.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**Added:** None

**Changed:** None

**Deprecated:** None

**Removed:**
* Code in mesh.py to reshpe a (N,1) to (N, ) array is no longer needed if PR #971 merged

**Fixed:** None

**Security:** None
11 changes: 11 additions & 0 deletions news/change_ebounds_unit_to_MeV.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**Added:** None

**Changed:** Unit of e_bounds changed from eV to MeV

**Deprecated:** None

**Removed:** None

**Fixed:** None

**Security:** None
13 changes: 13 additions & 0 deletions news/r2s_change_loop_variables_name.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**Added:** None

**Changed:**
* Change loop variables to be v for volume elements and e for energy groups (instead of i & j)
* Use bias_mode instead of mode to allow for additional mode types in future

**Deprecated:** None

**Removed:** None

**Fixed:** None

**Security:** None
12 changes: 12 additions & 0 deletions news/r2s_fix_wrong_mode_doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**Added:** None

**Changed:**
* Correct the wrong mode description comment in pyne/src/source_sampling.h

**Deprecated:** None

**Removed:** None

**Fixed:** None

**Security:** None
2 changes: 1 addition & 1 deletion pyne/alara.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def phtn_src_energy_bounds(input_file):
Returns
-------
e_bounds : list of floats
The lower and upper energy bounds for the photon_source discretization.
The lower and upper energy bounds for the photon_source discretization. Unit: eV.
"""
phtn_src_lines = ""
with open(input_file, 'r') as f:
Expand Down
5 changes: 0 additions & 5 deletions pyne/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,11 +1252,6 @@ def tag_cell_fracs(self, cell_fracs):
cell_largest_frac_number[i] = \
int(voxel_cell_number[i, largest_index])

# reshape the array
if max_num_cells == 1:
voxel_cell_number.shape = (num_vol_elements, )
voxel_cell_fracs.shape = (num_vol_elements, )

# create the tags
self.tag(name='cell_number', value=voxel_cell_number,
doc='cell numbers of the voxel, -1 used to fill vacancy',
Expand Down
1 change: 1 addition & 0 deletions scripts/r2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def step2():
e_bounds = phtn_src_energy_bounds("alara_geom")
e_bounds_str = ""
for e in e_bounds:
e = e/1e6 # convert unit to MeV
e_bounds_str += "{0}\n".format(e)
with open("e_bounds", 'w') as f:
f.write(e_bounds_str)
Expand Down
Loading

0 comments on commit 646ba5c

Please sign in to comment.