aboutsummaryrefslogtreecommitdiff
path: root/Source/Utils/write_atomic_data_cpp.py
diff options
context:
space:
mode:
authorGravatar Luca Fedeli <luca.fedeli@cea.fr> 2022-10-10 20:36:14 +0200
committerGravatar GitHub <noreply@github.com> 2022-10-10 11:36:14 -0700
commite9cc65ffeb0684a97618b67c2164d95ea497226c (patch)
treeed65f7ac86cc4e8945021dc36a79c8bc246c150d /Source/Utils/write_atomic_data_cpp.py
parent56e04c1b911f9399662c4ff9ecf6630d686cc220 (diff)
downloadWarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.tar.gz
WarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.tar.zst
WarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.zip
Partial refactoring of the utils directory (#3404)
* initial work to clean WarpX Utils * remove AMRCore from Ionization tables * progress * refactoring of a part of the utils directory * fix bug * fixed bug * fixed bug * remove debug line accidentally slipped into the code * remove debug line accidentally slipped into the code * remove debug line accidentally slipped into the code * cleaning * fixed bug
Diffstat (limited to 'Source/Utils/write_atomic_data_cpp.py')
-rw-r--r--Source/Utils/write_atomic_data_cpp.py87
1 files changed, 0 insertions, 87 deletions
diff --git a/Source/Utils/write_atomic_data_cpp.py b/Source/Utils/write_atomic_data_cpp.py
deleted file mode 100644
index 3b0538aa1..000000000
--- a/Source/Utils/write_atomic_data_cpp.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright 2019-2021 Axel Huebl, Luca Fedeli, Maxence Thevenet
-#
-#
-# This file is part of WarpX.
-#
-# License: BSD-3-Clause-LBNL
-
-'''
-This python script reads ionization tables in atomic_data.txt (generated from
-the NIST website) and extracts ionization levels into C++ file
-IonizationEnergiesTable.H, which contains tables + metadata.
-'''
-
-import os
-import re
-
-import numpy as np
-
-filename = os.path.join( '.', 'atomic_data.txt' )
-with open(filename) as f:
- text_data = f.read()
-
-# Read full table from file and get names, atomic numbers and offsets
-# position in table of ionization energies for all species
-regex_command = '\n\s+(\d+)\s+\|\s+([A-Z]+[a-z]*)\s+\w+\s+\|\s+\+*(\d+)\s+\|\s+\(*\[*(\d+\.*\d*)'
-list_of_tuples = re.findall( regex_command, text_data )
-ion_atom_numbers = [int(i) for i in list(dict.fromkeys( [x[0] for x in list_of_tuples] ))]
-ion_names = list(dict.fromkeys( [x[1] for x in list_of_tuples] ))
-ion_offsets = np.concatenate(([0], np.cumsum(np.array(ion_atom_numbers)[:-1])), axis=0)
-
-# Head of CPP file
-cpp_string = '// This script was automatically generated!\n'
-cpp_string += '// Edit dev/Source/Utils/write_atomic_data_cpp.py instead!\n'
-cpp_string += '#ifndef WARPX_IONIZATION_TABLE_H_\n'
-cpp_string += '#define WARPX_IONIZATION_TABLE_H_\n\n'
-cpp_string += '#include <AMReX_AmrCore.H>\n'
-cpp_string += '#include <AMReX_REAL.H>\n\n'
-cpp_string += '#include <map>\n'
-cpp_string += '#include <string>\n\n'
-
-# Map each element to ID in table
-cpp_string += 'static std::map<std::string, int> const ion_map_ids = {'
-for count, name in enumerate(ion_names):
- cpp_string += '\n {"' + name + '", ' + str(count) + '},'
-cpp_string = cpp_string[:-1]
-cpp_string += ' };\n\n'
-
-# Atomic number of each species
-cpp_string += 'constexpr int nelements = ' + str(len(ion_names)) + ';\n\n'
-cpp_string += 'constexpr int ion_atomic_numbers[nelements] = {\n '
-for count, atom_num in enumerate(ion_atom_numbers):
- if count%10==0 and count>0: cpp_string = cpp_string[:-2] + ',\n '
- cpp_string += str(atom_num) + ', '
-cpp_string = cpp_string[:-2]
-cpp_string += '};\n\n'
-
-# Offset of each element in table of ionization energies
-cpp_string += 'constexpr int ion_energy_offsets[nelements] = {\n '
-for count, offset in enumerate(ion_offsets):
- if count%10==0 and count>0: cpp_string = cpp_string[:-2] + ',\n '
- cpp_string += str(offset) + ', '
-cpp_string = cpp_string[:-2]
-cpp_string += '};\n\n'
-
-# Table of ionization energies
-cpp_string += 'constexpr int energies_tab_length = ' + str(len(list_of_tuples)) + ';\n\n'
-cpp_string += 'constexpr amrex::Real table_ionization_energies[energies_tab_length]{'
-for element in ion_names:
- cpp_string += '\n // ' + element + '\n '
- regex_command = \
- '\n\s+(\d+)\s+\|\s+%s\s+\w+\s+\|\s+\+*(\d+)\s+\|\s+\(*\[*(\d+\.*\d*)' \
- %element
- list_of_tuples = re.findall( regex_command, text_data )
- for count, energy in enumerate([x[2] for x in list_of_tuples]):
- if count%3==0 and count>0: cpp_string = cpp_string[:-2] + ',\n '
- cpp_string += "amrex::Real(" + energy + '), '
- cpp_string = cpp_string[:-1]
-cpp_string = cpp_string[:-1]
-cpp_string += '\n};\n\n'
-
-# Write the string to file
-cpp_string += '#endif // #ifndef WARPX_IONIZATION_TABLE_H_\n'
-f= open("IonizationEnergiesTable.H","w")
-f.write(cpp_string)
-f.close()