Compare commits
2 Commits
cjy-oneapi
...
yx-fmisc
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f7e20f702 | |||
| 673dd20722 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,7 +1,3 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
GW150914
|
GW150914
|
||||||
GW150914-origin
|
GW150914-origin
|
||||||
GW150914-mini
|
|
||||||
docs
|
|
||||||
*.tmp
|
|
||||||
|
|
||||||
445
AMSS_NCKU_ABEtest.py
Normal file
445
AMSS_NCKU_ABEtest.py
Normal file
@@ -0,0 +1,445 @@
|
|||||||
|
|
||||||
|
##################################################################
|
||||||
|
##
|
||||||
|
## AMSS-NCKU ABE Test Program (Skip TwoPuncture if data exists)
|
||||||
|
## Modified from AMSS_NCKU_Program.py
|
||||||
|
## Author: Xiaoqu
|
||||||
|
## Modified: 2026/02/01
|
||||||
|
##
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Print program introduction
|
||||||
|
|
||||||
|
import print_information
|
||||||
|
|
||||||
|
print_information.print_program_introduction()
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
import AMSS_NCKU_Input as input_data
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Create directories to store program run data
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
## Set the output directory according to the input file
|
||||||
|
File_directory = os.path.join(input_data.File_directory)
|
||||||
|
|
||||||
|
## Check if output directory exists and if TwoPuncture data is available
|
||||||
|
skip_twopuncture = False
|
||||||
|
output_directory = os.path.join(File_directory, "AMSS_NCKU_output")
|
||||||
|
binary_results_directory = os.path.join(output_directory, input_data.Output_directory)
|
||||||
|
|
||||||
|
if os.path.exists(File_directory):
|
||||||
|
print( " Output directory already exists." )
|
||||||
|
print()
|
||||||
|
|
||||||
|
# Check if TwoPuncture initial data files exist
|
||||||
|
if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture"):
|
||||||
|
twopuncture_output = os.path.join(output_directory, "TwoPunctureABE")
|
||||||
|
input_par = os.path.join(output_directory, "input.par")
|
||||||
|
|
||||||
|
if os.path.exists(twopuncture_output) and os.path.exists(input_par):
|
||||||
|
print( " Found existing TwoPuncture initial data." )
|
||||||
|
print( " Do you want to skip TwoPuncture phase and reuse existing data?" )
|
||||||
|
print( " Input 'skip' to skip TwoPuncture and start ABE directly" )
|
||||||
|
print( " Input 'regenerate' to regenerate everything from scratch" )
|
||||||
|
print()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
inputvalue = input()
|
||||||
|
if ( inputvalue == "skip" ):
|
||||||
|
print( " Skipping TwoPuncture phase, will reuse existing initial data." )
|
||||||
|
print()
|
||||||
|
skip_twopuncture = True
|
||||||
|
break
|
||||||
|
elif ( inputvalue == "regenerate" ):
|
||||||
|
print( " Regenerating everything from scratch." )
|
||||||
|
print()
|
||||||
|
skip_twopuncture = False
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print( " Please input 'skip' or 'regenerate'." )
|
||||||
|
except ValueError:
|
||||||
|
print( " Please input 'skip' or 'regenerate'." )
|
||||||
|
else:
|
||||||
|
print( " TwoPuncture initial data not found, will regenerate everything." )
|
||||||
|
print()
|
||||||
|
|
||||||
|
# If not skipping, remove and recreate directory
|
||||||
|
if not skip_twopuncture:
|
||||||
|
shutil.rmtree(File_directory, ignore_errors=True)
|
||||||
|
os.mkdir(File_directory)
|
||||||
|
os.mkdir(output_directory)
|
||||||
|
os.mkdir(binary_results_directory)
|
||||||
|
figure_directory = os.path.join(File_directory, "figure")
|
||||||
|
os.mkdir(figure_directory)
|
||||||
|
shutil.copy("AMSS_NCKU_Input.py", File_directory)
|
||||||
|
print( " Output directory has been regenerated." )
|
||||||
|
print()
|
||||||
|
else:
|
||||||
|
# Create fresh directory structure
|
||||||
|
os.mkdir(File_directory)
|
||||||
|
shutil.copy("AMSS_NCKU_Input.py", File_directory)
|
||||||
|
os.mkdir(output_directory)
|
||||||
|
os.mkdir(binary_results_directory)
|
||||||
|
figure_directory = os.path.join(File_directory, "figure")
|
||||||
|
os.mkdir(figure_directory)
|
||||||
|
print( " Output directory has been generated." )
|
||||||
|
print()
|
||||||
|
|
||||||
|
# Ensure figure directory exists
|
||||||
|
figure_directory = os.path.join(File_directory, "figure")
|
||||||
|
if not os.path.exists(figure_directory):
|
||||||
|
os.mkdir(figure_directory)
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Output related parameter information
|
||||||
|
|
||||||
|
import setup
|
||||||
|
|
||||||
|
## Print and save input parameter information
|
||||||
|
setup.print_input_data( File_directory )
|
||||||
|
|
||||||
|
if not skip_twopuncture:
|
||||||
|
setup.generate_AMSSNCKU_input()
|
||||||
|
|
||||||
|
setup.print_puncture_information()
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Generate AMSS-NCKU program input files based on the configured parameters
|
||||||
|
|
||||||
|
if not skip_twopuncture:
|
||||||
|
print()
|
||||||
|
print( " Generating the AMSS-NCKU input parfile for the ABE executable." )
|
||||||
|
print()
|
||||||
|
|
||||||
|
## Generate cgh-related input files from the grid information
|
||||||
|
|
||||||
|
import numerical_grid
|
||||||
|
|
||||||
|
numerical_grid.append_AMSSNCKU_cgh_input()
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( " The input parfile for AMSS-NCKU C++ executable file ABE has been generated." )
|
||||||
|
print( " However, the input relevant to TwoPuncture need to be appended later." )
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Plot the initial grid configuration
|
||||||
|
|
||||||
|
if not skip_twopuncture:
|
||||||
|
print()
|
||||||
|
print( " Schematically plot the numerical grid structure." )
|
||||||
|
print()
|
||||||
|
|
||||||
|
import numerical_grid
|
||||||
|
numerical_grid.plot_initial_grid()
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Generate AMSS-NCKU macro files according to the numerical scheme and parameters
|
||||||
|
|
||||||
|
if not skip_twopuncture:
|
||||||
|
print()
|
||||||
|
print( " Automatically generating the macro file for AMSS-NCKU C++ executable file ABE " )
|
||||||
|
print( " (Based on the finite-difference numerical scheme) " )
|
||||||
|
print()
|
||||||
|
|
||||||
|
import generate_macrodef
|
||||||
|
|
||||||
|
generate_macrodef.generate_macrodef_h()
|
||||||
|
print( " AMSS-NCKU macro file macrodef.h has been generated. " )
|
||||||
|
|
||||||
|
generate_macrodef.generate_macrodef_fh()
|
||||||
|
print( " AMSS-NCKU macro file macrodef.fh has been generated. " )
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
# Compile the AMSS-NCKU program according to user requirements
|
||||||
|
# NOTE: ABE compilation is always performed, even when skipping TwoPuncture
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( " Preparing to compile and run the AMSS-NCKU code as requested " )
|
||||||
|
print( " Compiling the AMSS-NCKU code based on the generated macro files " )
|
||||||
|
print()
|
||||||
|
|
||||||
|
AMSS_NCKU_source_path = "AMSS_NCKU_source"
|
||||||
|
AMSS_NCKU_source_copy = os.path.join(File_directory, "AMSS_NCKU_source_copy")
|
||||||
|
|
||||||
|
## If AMSS_NCKU source folder is missing, create it and prompt the user
|
||||||
|
if not os.path.exists(AMSS_NCKU_source_path):
|
||||||
|
os.makedirs(AMSS_NCKU_source_path)
|
||||||
|
print( " The AMSS-NCKU source files are incomplete; copy all source files into ./AMSS_NCKU_source. " )
|
||||||
|
print( " Press Enter to continue. " )
|
||||||
|
inputvalue = input()
|
||||||
|
|
||||||
|
# Copy AMSS-NCKU source files to prepare for compilation
|
||||||
|
# If skipping TwoPuncture and source_copy already exists, remove it first
|
||||||
|
if skip_twopuncture and os.path.exists(AMSS_NCKU_source_copy):
|
||||||
|
shutil.rmtree(AMSS_NCKU_source_copy)
|
||||||
|
|
||||||
|
shutil.copytree(AMSS_NCKU_source_path, AMSS_NCKU_source_copy)
|
||||||
|
|
||||||
|
# Copy the generated macro files into the AMSS_NCKU source folder
|
||||||
|
if not skip_twopuncture:
|
||||||
|
macrodef_h_path = os.path.join(File_directory, "macrodef.h")
|
||||||
|
macrodef_fh_path = os.path.join(File_directory, "macrodef.fh")
|
||||||
|
else:
|
||||||
|
# When skipping TwoPuncture, use existing macro files from previous run
|
||||||
|
macrodef_h_path = os.path.join(File_directory, "macrodef.h")
|
||||||
|
macrodef_fh_path = os.path.join(File_directory, "macrodef.fh")
|
||||||
|
|
||||||
|
shutil.copy2(macrodef_h_path, AMSS_NCKU_source_copy)
|
||||||
|
shutil.copy2(macrodef_fh_path, AMSS_NCKU_source_copy)
|
||||||
|
|
||||||
|
# Compile related programs
|
||||||
|
import makefile_and_run
|
||||||
|
|
||||||
|
## Change working directory to the target source copy
|
||||||
|
os.chdir(AMSS_NCKU_source_copy)
|
||||||
|
|
||||||
|
## Build the main AMSS-NCKU executable (ABE or ABEGPU)
|
||||||
|
makefile_and_run.makefile_ABE()
|
||||||
|
|
||||||
|
## If the initial-data method is Ansorg-TwoPuncture, build the TwoPunctureABE executable
|
||||||
|
## Only build TwoPunctureABE if not skipping TwoPuncture phase
|
||||||
|
if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ) and not skip_twopuncture:
|
||||||
|
makefile_and_run.makefile_TwoPunctureABE()
|
||||||
|
|
||||||
|
## Change current working directory back up two levels
|
||||||
|
os.chdir('..')
|
||||||
|
os.chdir('..')
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Copy the AMSS-NCKU executable (ABE/ABEGPU) to the run directory
|
||||||
|
|
||||||
|
if (input_data.GPU_Calculation == "no"):
|
||||||
|
ABE_file = os.path.join(AMSS_NCKU_source_copy, "ABE")
|
||||||
|
elif (input_data.GPU_Calculation == "yes"):
|
||||||
|
ABE_file = os.path.join(AMSS_NCKU_source_copy, "ABEGPU")
|
||||||
|
|
||||||
|
if not os.path.exists( ABE_file ):
|
||||||
|
print()
|
||||||
|
print( " Lack of AMSS-NCKU executable file ABE/ABEGPU; recompile AMSS_NCKU_source manually. " )
|
||||||
|
print( " When recompilation is finished, press Enter to continue. " )
|
||||||
|
inputvalue = input()
|
||||||
|
|
||||||
|
## Copy the executable ABE (or ABEGPU) into the run directory
|
||||||
|
shutil.copy2(ABE_file, output_directory)
|
||||||
|
|
||||||
|
## If the initial-data method is TwoPuncture, copy the TwoPunctureABE executable to the run directory
|
||||||
|
## Only copy TwoPunctureABE if not skipping TwoPuncture phase
|
||||||
|
if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ) and not skip_twopuncture:
|
||||||
|
TwoPuncture_file = os.path.join(AMSS_NCKU_source_copy, "TwoPunctureABE")
|
||||||
|
|
||||||
|
if not os.path.exists( TwoPuncture_file ):
|
||||||
|
print()
|
||||||
|
print( " Lack of AMSS-NCKU executable file TwoPunctureABE; recompile TwoPunctureABE in AMSS_NCKU_source. " )
|
||||||
|
print( " When recompilation is finished, press Enter to continue. " )
|
||||||
|
inputvalue = input()
|
||||||
|
|
||||||
|
## Copy the TwoPunctureABE executable into the run directory
|
||||||
|
shutil.copy2(TwoPuncture_file, output_directory)
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## If the initial-data method is TwoPuncture, generate the TwoPuncture input files
|
||||||
|
|
||||||
|
if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ) and not skip_twopuncture:
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( " Initial data is chosen as Ansorg-TwoPuncture" )
|
||||||
|
print()
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( " Automatically generating the input parfile for the TwoPunctureABE executable " )
|
||||||
|
print()
|
||||||
|
|
||||||
|
import generate_TwoPuncture_input
|
||||||
|
|
||||||
|
generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input()
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( " The input parfile for the TwoPunctureABE executable has been generated. " )
|
||||||
|
print()
|
||||||
|
|
||||||
|
## Generated AMSS-NCKU TwoPuncture input filename
|
||||||
|
AMSS_NCKU_TwoPuncture_inputfile = 'AMSS-NCKU-TwoPuncture.input'
|
||||||
|
AMSS_NCKU_TwoPuncture_inputfile_path = os.path.join( File_directory, AMSS_NCKU_TwoPuncture_inputfile )
|
||||||
|
|
||||||
|
## Copy and rename the file
|
||||||
|
shutil.copy2( AMSS_NCKU_TwoPuncture_inputfile_path, os.path.join(output_directory, 'TwoPunctureinput.par') )
|
||||||
|
|
||||||
|
## Run TwoPuncture to generate initial-data files
|
||||||
|
|
||||||
|
start_time = time.time() # Record start time
|
||||||
|
|
||||||
|
print()
|
||||||
|
print()
|
||||||
|
|
||||||
|
## Change to the output (run) directory
|
||||||
|
os.chdir(output_directory)
|
||||||
|
|
||||||
|
## Run the TwoPuncture executable
|
||||||
|
import makefile_and_run
|
||||||
|
makefile_and_run.run_TwoPunctureABE()
|
||||||
|
|
||||||
|
## Change current working directory back up two levels
|
||||||
|
os.chdir('..')
|
||||||
|
os.chdir('..')
|
||||||
|
|
||||||
|
elif (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ) and skip_twopuncture:
|
||||||
|
print()
|
||||||
|
print( " Skipping TwoPuncture execution, using existing initial data." )
|
||||||
|
print()
|
||||||
|
start_time = time.time() # Record start time for ABE only
|
||||||
|
else:
|
||||||
|
start_time = time.time() # Record start time
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Update puncture data based on TwoPuncture run results
|
||||||
|
|
||||||
|
if not skip_twopuncture:
|
||||||
|
import renew_puncture_parameter
|
||||||
|
renew_puncture_parameter.append_AMSSNCKU_BSSN_input(File_directory, output_directory)
|
||||||
|
|
||||||
|
## Generated AMSS-NCKU input filename
|
||||||
|
AMSS_NCKU_inputfile = 'AMSS-NCKU.input'
|
||||||
|
AMSS_NCKU_inputfile_path = os.path.join(File_directory, AMSS_NCKU_inputfile)
|
||||||
|
|
||||||
|
## Copy and rename the file
|
||||||
|
shutil.copy2( AMSS_NCKU_inputfile_path, os.path.join(output_directory, 'input.par') )
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( " Successfully copy all AMSS-NCKU input parfile to target dictionary. " )
|
||||||
|
print()
|
||||||
|
else:
|
||||||
|
print()
|
||||||
|
print( " Using existing input.par file from previous run." )
|
||||||
|
print()
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Launch the AMSS-NCKU program
|
||||||
|
|
||||||
|
print()
|
||||||
|
print()
|
||||||
|
|
||||||
|
## Change to the run directory
|
||||||
|
os.chdir( output_directory )
|
||||||
|
|
||||||
|
import makefile_and_run
|
||||||
|
makefile_and_run.run_ABE()
|
||||||
|
|
||||||
|
## Change current working directory back up two levels
|
||||||
|
os.chdir('..')
|
||||||
|
os.chdir('..')
|
||||||
|
|
||||||
|
end_time = time.time()
|
||||||
|
elapsed_time = end_time - start_time
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Copy some basic input and log files out to facilitate debugging
|
||||||
|
|
||||||
|
## Path to the file that stores calculation settings
|
||||||
|
AMSS_NCKU_error_file_path = os.path.join(binary_results_directory, "setting.par")
|
||||||
|
## Copy and rename the file for easier inspection
|
||||||
|
shutil.copy( AMSS_NCKU_error_file_path, os.path.join(output_directory, "AMSSNCKU_setting_parameter") )
|
||||||
|
|
||||||
|
## Path to the error log file
|
||||||
|
AMSS_NCKU_error_file_path = os.path.join(binary_results_directory, "Error.log")
|
||||||
|
## Copy and rename the error log
|
||||||
|
shutil.copy( AMSS_NCKU_error_file_path, os.path.join(output_directory, "Error.log") )
|
||||||
|
|
||||||
|
## Primary program outputs
|
||||||
|
AMSS_NCKU_BH_data = os.path.join(binary_results_directory, "bssn_BH.dat" )
|
||||||
|
AMSS_NCKU_ADM_data = os.path.join(binary_results_directory, "bssn_ADMQs.dat" )
|
||||||
|
AMSS_NCKU_psi4_data = os.path.join(binary_results_directory, "bssn_psi4.dat" )
|
||||||
|
AMSS_NCKU_constraint_data = os.path.join(binary_results_directory, "bssn_constraint.dat")
|
||||||
|
## copy and rename the file
|
||||||
|
shutil.copy( AMSS_NCKU_BH_data, os.path.join(output_directory, "bssn_BH.dat" ) )
|
||||||
|
shutil.copy( AMSS_NCKU_ADM_data, os.path.join(output_directory, "bssn_ADMQs.dat" ) )
|
||||||
|
shutil.copy( AMSS_NCKU_psi4_data, os.path.join(output_directory, "bssn_psi4.dat" ) )
|
||||||
|
shutil.copy( AMSS_NCKU_constraint_data, os.path.join(output_directory, "bssn_constraint.dat") )
|
||||||
|
|
||||||
|
## Additional program outputs
|
||||||
|
if (input_data.Equation_Class == "BSSN-EM"):
|
||||||
|
AMSS_NCKU_phi1_data = os.path.join(binary_results_directory, "bssn_phi1.dat" )
|
||||||
|
AMSS_NCKU_phi2_data = os.path.join(binary_results_directory, "bssn_phi2.dat" )
|
||||||
|
shutil.copy( AMSS_NCKU_phi1_data, os.path.join(output_directory, "bssn_phi1.dat" ) )
|
||||||
|
shutil.copy( AMSS_NCKU_phi2_data, os.path.join(output_directory, "bssn_phi2.dat" ) )
|
||||||
|
elif (input_data.Equation_Class == "BSSN-EScalar"):
|
||||||
|
AMSS_NCKU_maxs_data = os.path.join(binary_results_directory, "bssn_maxs.dat" )
|
||||||
|
shutil.copy( AMSS_NCKU_maxs_data, os.path.join(output_directory, "bssn_maxs.dat" ) )
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
## Plot the AMSS-NCKU program results
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( " Plotting the txt and binary results data from the AMSS-NCKU simulation " )
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
import plot_xiaoqu
|
||||||
|
import plot_GW_strain_amplitude_xiaoqu
|
||||||
|
|
||||||
|
## Plot black hole trajectory
|
||||||
|
plot_xiaoqu.generate_puncture_orbit_plot( binary_results_directory, figure_directory )
|
||||||
|
plot_xiaoqu.generate_puncture_orbit_plot3D( binary_results_directory, figure_directory )
|
||||||
|
|
||||||
|
## Plot black hole separation vs. time
|
||||||
|
plot_xiaoqu.generate_puncture_distence_plot( binary_results_directory, figure_directory )
|
||||||
|
|
||||||
|
## Plot gravitational waveforms (psi4 and strain amplitude)
|
||||||
|
for i in range(input_data.Detector_Number):
|
||||||
|
plot_xiaoqu.generate_gravitational_wave_psi4_plot( binary_results_directory, figure_directory, i )
|
||||||
|
plot_GW_strain_amplitude_xiaoqu.generate_gravitational_wave_amplitude_plot( binary_results_directory, figure_directory, i )
|
||||||
|
|
||||||
|
## Plot ADM mass evolution
|
||||||
|
for i in range(input_data.Detector_Number):
|
||||||
|
plot_xiaoqu.generate_ADMmass_plot( binary_results_directory, figure_directory, i )
|
||||||
|
|
||||||
|
## Plot Hamiltonian constraint violation over time
|
||||||
|
for i in range(input_data.grid_level):
|
||||||
|
plot_xiaoqu.generate_constraint_check_plot( binary_results_directory, figure_directory, i )
|
||||||
|
|
||||||
|
## Plot stored binary data
|
||||||
|
plot_xiaoqu.generate_binary_data_plot( binary_results_directory, figure_directory )
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( f" This Program Cost = {elapsed_time} Seconds " )
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
print()
|
||||||
|
print( " The AMSS-NCKU-Python simulation is successfully finished, thanks for using !!! " )
|
||||||
|
print()
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
|
||||||
@@ -16,14 +16,12 @@ import numpy
|
|||||||
File_directory = "GW150914" ## output file directory
|
File_directory = "GW150914" ## output file directory
|
||||||
Output_directory = "binary_output" ## binary data file directory
|
Output_directory = "binary_output" ## binary data file directory
|
||||||
## The file directory name should not be too long
|
## The file directory name should not be too long
|
||||||
MPI_processes = 8 ## number of mpi processes used in the simulation
|
MPI_processes = 64 ## number of mpi processes used in the simulation
|
||||||
|
|
||||||
GPU_Calculation = "no" ## Use GPU or not
|
GPU_Calculation = "no" ## Use GPU or not
|
||||||
## (prefer "no" in the current version, because the GPU part may have bugs when integrated in this Python interface)
|
## (prefer "no" in the current version, because the GPU part may have bugs when integrated in this Python interface)
|
||||||
CPU_Part = 1.0
|
CPU_Part = 1.0
|
||||||
GPU_Part = 0.0
|
GPU_Part = 0.0
|
||||||
Debug_NaN_Check = 0 ## enable NaN checks in compute_rhs_bssn: 0 (off) or 1 (on)
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
|
|||||||
@@ -1,233 +0,0 @@
|
|||||||
|
|
||||||
#################################################
|
|
||||||
##
|
|
||||||
## This file provides the input parameters required for numerical relativity.
|
|
||||||
## XIAOQU
|
|
||||||
## 2024/03/19 --- 2025/09/14
|
|
||||||
## Modified for GW150914-mini test case
|
|
||||||
##
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
import numpy
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Setting MPI processes and the output file directory
|
|
||||||
|
|
||||||
File_directory = "GW150914-mini" ## output file directory
|
|
||||||
Output_directory = "binary_output" ## binary data file directory
|
|
||||||
## The file directory name should not be too long
|
|
||||||
MPI_processes = 4 ## number of mpi processes used in the simulation (Reduced for laptop)
|
|
||||||
|
|
||||||
GPU_Calculation = "no" ## Use GPU or not
|
|
||||||
## (prefer "no" in the current version, because the GPU part may have bugs when integrated in this Python interface)
|
|
||||||
CPU_Part = 1.0
|
|
||||||
GPU_Part = 0.0
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Setting the physical system and numerical method
|
|
||||||
|
|
||||||
Symmetry = "equatorial-symmetry" ## Symmetry of System: choose equatorial-symmetry、no-symmetry、octant-symmetry
|
|
||||||
Equation_Class = "BSSN" ## Evolution Equation: choose "BSSN", "BSSN-EScalar", "BSSN-EM", "Z4C"
|
|
||||||
## If "BSSN-EScalar" is chosen, it is necessary to set other parameters below
|
|
||||||
Initial_Data_Method = "Ansorg-TwoPuncture" ## initial data method: choose "Ansorg-TwoPuncture", "Lousto-Analytical", "Cao-Analytical", "KerrSchild-Analytical"
|
|
||||||
Time_Evolution_Method = "runge-kutta-45" ## time evolution method: choose "runge-kutta-45"
|
|
||||||
Finite_Diffenence_Method = "4th-order" ## finite-difference method: choose "2nd-order", "4th-order", "6th-order", "8th-order"
|
|
||||||
Debug_NaN_Check = 0 ## enable NaN checks in compute_rhs_bssn: 0 (off) or 1 (on)
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Setting the time evolutionary information
|
|
||||||
|
|
||||||
Start_Evolution_Time = 0.0 ## start evolution time t0
|
|
||||||
Final_Evolution_Time = 100.0 ## final evolution time t1 (Reduced for quick test)
|
|
||||||
Check_Time = 10.0
|
|
||||||
Dump_Time = 10.0 ## time inteval dT for dumping binary data
|
|
||||||
D2_Dump_Time = 10.0 ## dump the ascii data for 2d surface after dT'
|
|
||||||
Analysis_Time = 1.0 ## dump the puncture position and GW psi4 after dT"
|
|
||||||
Evolution_Step_Number = 10000000 ## stop the calculation after the maximal step number
|
|
||||||
Courant_Factor = 0.5 ## Courant Factor
|
|
||||||
Dissipation = 0.15 ## Kreiss-Oliger Dissipation Strength
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Setting the grid structure
|
|
||||||
|
|
||||||
basic_grid_set = "Patch" ## grid structure: choose "Patch" or "Shell-Patch"
|
|
||||||
grid_center_set = "Cell" ## grid center: chose "Cell" or "Vertex"
|
|
||||||
|
|
||||||
grid_level = 7 ## total number of AMR grid levels (Reduced from 9)
|
|
||||||
static_grid_level = 4 ## number of AMR static grid levels (Reduced from 5)
|
|
||||||
moving_grid_level = grid_level - static_grid_level ## number of AMR moving grid levels
|
|
||||||
|
|
||||||
analysis_level = 0
|
|
||||||
refinement_level = 3 ## time refinement start from this grid level
|
|
||||||
|
|
||||||
largest_box_xyz_max = [320.0, 320.0, 320.0] ## scale of the largest box
|
|
||||||
## not ne cess ary to be cubic for "Patch" grid s tructure
|
|
||||||
## need to be a cubic box for "Shell-Patch" grid structure
|
|
||||||
largest_box_xyz_min = - numpy.array(largest_box_xyz_max)
|
|
||||||
|
|
||||||
static_grid_number = 48 ## grid points of each static AMR grid (in x direction) (Reduced from 96)
|
|
||||||
## (grid points in y and z directions are automatically adjusted)
|
|
||||||
moving_grid_number = 24 ## grid points of each moving AMR grid (Reduced from 48)
|
|
||||||
shell_grid_number = [32, 32, 100] ## grid points of Shell-Patch grid
|
|
||||||
## in (phi, theta, r) direction
|
|
||||||
devide_factor = 2.0 ## resolution between different grid levels dh0/dh1, only support 2.0 now
|
|
||||||
|
|
||||||
|
|
||||||
static_grid_type = 'Linear' ## AMR static grid structure , only supports "Linear"
|
|
||||||
moving_grid_type = 'Linear' ## AMR moving grid structure , only supports "Linear"
|
|
||||||
|
|
||||||
quarter_sphere_number = 48 ## grid number of 1/4 s pher ical surface (Reduced from 96)
|
|
||||||
## (which is needed for evaluating the spherical surface integral)
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Setting the puncture information
|
|
||||||
|
|
||||||
puncture_number = 2
|
|
||||||
|
|
||||||
position_BH = numpy.zeros( (puncture_number, 3) )
|
|
||||||
parameter_BH = numpy.zeros( (puncture_number, 3) )
|
|
||||||
dimensionless_spin_BH = numpy.zeros( (puncture_number, 3) )
|
|
||||||
momentum_BH = numpy.zeros( (puncture_number, 3) )
|
|
||||||
|
|
||||||
puncture_data_set = "Manually" ## Method to give Puncture’s positions and momentum
|
|
||||||
## choose "Manually" or "Automatically-BBH"
|
|
||||||
## Prefer to choose "Manually", because "Automatically-BBH" is developing now
|
|
||||||
|
|
||||||
## initial orbital distance and ellipticity for BBHs system
|
|
||||||
## ( needed for "Automatically-BBH" case , not affect the "Manually" case )
|
|
||||||
Distance = 10.0
|
|
||||||
e0 = 0.0
|
|
||||||
|
|
||||||
## black hole parameter (M Q* a*)
|
|
||||||
parameter_BH[0] = [ 36.0/(36.0+29.0), 0.0, +0.31 ]
|
|
||||||
parameter_BH[1] = [ 29.0/(36.0+29.0), 0.0, -0.46 ]
|
|
||||||
## dimensionless spin in each direction
|
|
||||||
dimensionless_spin_BH[0] = [ 0.0, 0.0, +0.31 ]
|
|
||||||
dimensionless_spin_BH[1] = [ 0.0, 0.0, -0.46 ]
|
|
||||||
|
|
||||||
## use Brugmann's convention
|
|
||||||
## -----0-----> y
|
|
||||||
## - +
|
|
||||||
|
|
||||||
#---------------------------------------------
|
|
||||||
|
|
||||||
## If puncture_data_set is chosen to be "Manually", it is necessary to set the position and momentum of each puncture manually
|
|
||||||
|
|
||||||
## initial position for each puncture
|
|
||||||
position_BH[0] = [ 0.0, 10.0*29.0/(36.0+29.0), 0.0 ]
|
|
||||||
position_BH[1] = [ 0.0, -10.0*36.0/(36.0+29.0), 0.0 ]
|
|
||||||
|
|
||||||
## initial mumentum for each puncture
|
|
||||||
## (needed for "Manually" case, does not affect the "Automatically-BBH" case)
|
|
||||||
momentum_BH[0] = [ -0.09530152296974252, -0.00084541526517121, 0.0 ]
|
|
||||||
momentum_BH[1] = [ +0.09530152296974252, +0.00084541526517121, 0.0 ]
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Setting the gravitational wave information
|
|
||||||
|
|
||||||
GW_L_max = 4 ## maximal L number in gravitational wave
|
|
||||||
GW_M_max = 4 ## maximal M number in gravitational wave
|
|
||||||
Detector_Number = 12 ## number of dector
|
|
||||||
Detector_Rmin = 50.0 ## nearest dector distance
|
|
||||||
Detector_Rmax = 160.0 ## farest dector distance
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Setting the apprent horizon
|
|
||||||
|
|
||||||
AHF_Find = "no" ## whether to find the apparent horizon: choose "yes" or "no"
|
|
||||||
|
|
||||||
AHF_Find_Every = 24
|
|
||||||
AHF_Dump_Time = 20.0
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Other parameters (testing)
|
|
||||||
## Only influence the Equation_Class = "BSSN-EScalar" case
|
|
||||||
|
|
||||||
FR_a2 = 3.0 ## f(R) = R + a2 * R^2
|
|
||||||
FR_l2 = 10000.0
|
|
||||||
FR_phi0 = 0.00005
|
|
||||||
FR_r0 = 120.0
|
|
||||||
FR_sigma0 = 8.0
|
|
||||||
FR_Choice = 2 ## Choice options: 1 2 3 4 5
|
|
||||||
## 1: phi(r) = phi0 * Exp(-(r-r0)**2/sigma0)
|
|
||||||
## V(r) = 0
|
|
||||||
## 2: phi(r) = phi0 * a2^2/(1+a2^2)
|
|
||||||
## V(r) = Exp(-8*Sqrt(PI/3)*phi(r)) * (1-Exp(4*Sqrt(PI/3)*phi(r)))**2 / (32*PI*a2)
|
|
||||||
## 3: Schrodinger-Newton gived by system phi(r)
|
|
||||||
## V(r) = Exp(-8*Sqrt(PI/3)*phi(r)) * (1-Exp(4*Sqrt(PI/3)*phi(r)))**2 / (32*PI*a2)
|
|
||||||
## 4: phi(r) = phi0 * 0.5 * ( tanh((r+r0)/sigma0) - tanh((r-r0)/sigma0) )
|
|
||||||
## V(r) = 0
|
|
||||||
## f(R) = R + a2*R^2 with a2 = +oo
|
|
||||||
## 5: phi(r) = phi0 * Exp(-(r-r0)**2/sigma)
|
|
||||||
## V(r) = 0
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
|
|
||||||
## Other parameters (testing)
|
|
||||||
## (please do not change if not necessary)
|
|
||||||
|
|
||||||
boundary_choice = "BAM-choice" ## Sommerfeld boundary condition : choose "BAM-choice" or "Shibata-choice"
|
|
||||||
## prefer "BAM-choice"
|
|
||||||
|
|
||||||
gauge_choice = 0 ## gauge choice
|
|
||||||
## 0: B^i gauge
|
|
||||||
## 1: David's puncture gauge
|
|
||||||
## 2: MB B^i gauge
|
|
||||||
## 3: RIT B^i gauge
|
|
||||||
## 4: MB beta gauge
|
|
||||||
## 5: RIT beta gauge
|
|
||||||
## 6: MGB1 B^i gauge
|
|
||||||
## 7: MGB2 B^i gauge
|
|
||||||
## prefer 0 or 1
|
|
||||||
|
|
||||||
tetrad_type = 2 ## tetradtype
|
|
||||||
## v:r; u: phi; w: theta
|
|
||||||
## v^a = (x,y,z)
|
|
||||||
## 0: orthonormal order: v,u,w
|
|
||||||
## v^a = (x,y,z)
|
|
||||||
## m = (phi - i theta)/sqrt(2)
|
|
||||||
## following Frans, Eq.(8) of PRD 75, 124018(2007)
|
|
||||||
## 1: orthonormal order: w,u,v
|
|
||||||
## m = (theta + i phi)/sqrt(2)
|
|
||||||
## following Sperhake, Eq.(3.2) of PRD 85, 124062(2012)
|
|
||||||
## 2: orthonormal order: v,u,w
|
|
||||||
## v_a = (x,y,z)
|
|
||||||
## m = (phi - i theta)/sqrt(2)
|
|
||||||
## following Frans, Eq.(8) of PRD 75, 124018(2007)
|
|
||||||
## this version recommend set to 2
|
|
||||||
## prefer 2
|
|
||||||
|
|
||||||
#################################################
|
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
##################################################################
|
|
||||||
##
|
|
||||||
## AMSS-NCKU Numerical Relativity Mini Test Program
|
|
||||||
## Author: Assistant (based on Xiaoqu's code)
|
|
||||||
## 2026/01/20
|
|
||||||
##
|
|
||||||
## This script runs a scaled-down version of the GW150914 test case
|
|
||||||
## suitable for laptop testing.
|
|
||||||
##
|
|
||||||
##################################################################
|
|
||||||
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
# --- Context Manager for Input File Swapping ---
|
|
||||||
class InputFileSwapper:
|
|
||||||
def __init__(self, mini_file="AMSS_NCKU_Input_Mini.py", target_file="AMSS_NCKU_Input.py"):
|
|
||||||
self.mini_file = mini_file
|
|
||||||
self.target_file = target_file
|
|
||||||
self.backup_file = target_file + ".bak"
|
|
||||||
self.swapped = False
|
|
||||||
|
|
||||||
def __enter__(self):
|
|
||||||
print(f"[MiniProgram] Swapping {self.target_file} with {self.mini_file}...")
|
|
||||||
if os.path.exists(self.target_file):
|
|
||||||
shutil.move(self.target_file, self.backup_file)
|
|
||||||
shutil.copy(self.mini_file, self.target_file)
|
|
||||||
self.swapped = True
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
|
||||||
if self.swapped:
|
|
||||||
print(f"[MiniProgram] Restoring original {self.target_file}...")
|
|
||||||
os.remove(self.target_file)
|
|
||||||
if os.path.exists(self.backup_file):
|
|
||||||
shutil.move(self.backup_file, self.target_file)
|
|
||||||
|
|
||||||
def main():
|
|
||||||
# Use the swapper to ensure all imported modules see the mini configuration
|
|
||||||
with InputFileSwapper():
|
|
||||||
|
|
||||||
# Import modules AFTER swapping input file
|
|
||||||
try:
|
|
||||||
import AMSS_NCKU_Input as input_data
|
|
||||||
import print_information
|
|
||||||
import setup
|
|
||||||
import numerical_grid
|
|
||||||
import generate_macrodef
|
|
||||||
import makefile_and_run
|
|
||||||
import generate_TwoPuncture_input
|
|
||||||
import renew_puncture_parameter
|
|
||||||
import plot_xiaoqu
|
|
||||||
import plot_GW_strain_amplitude_xiaoqu
|
|
||||||
except ImportError as e:
|
|
||||||
print(f"Error importing modules: {e}")
|
|
||||||
return
|
|
||||||
|
|
||||||
print_information.print_program_introduction()
|
|
||||||
|
|
||||||
print("\n" + "#"*60)
|
|
||||||
print(" RUNNING MINI TEST CASE: GW150914-mini")
|
|
||||||
print("#"*60 + "\n")
|
|
||||||
|
|
||||||
# --- Directory Setup ---
|
|
||||||
File_directory = os.path.join(input_data.File_directory)
|
|
||||||
|
|
||||||
if os.path.exists(File_directory):
|
|
||||||
print(f" Output directory '{File_directory}' exists. Removing for mini test...")
|
|
||||||
shutil.rmtree(File_directory, ignore_errors=True)
|
|
||||||
|
|
||||||
os.mkdir(File_directory)
|
|
||||||
shutil.copy("AMSS_NCKU_Input.py", File_directory) # Copies the current (mini) input
|
|
||||||
|
|
||||||
output_directory = os.path.join(File_directory, "AMSS_NCKU_output")
|
|
||||||
os.mkdir(output_directory)
|
|
||||||
|
|
||||||
binary_results_directory = os.path.join(output_directory, input_data.Output_directory)
|
|
||||||
os.mkdir(binary_results_directory)
|
|
||||||
|
|
||||||
figure_directory = os.path.join(File_directory, "figure")
|
|
||||||
os.mkdir(figure_directory)
|
|
||||||
|
|
||||||
print(" Output directories generated.\n")
|
|
||||||
|
|
||||||
# --- Setup and Input Generation ---
|
|
||||||
setup.print_input_data(File_directory)
|
|
||||||
setup.generate_AMSSNCKU_input()
|
|
||||||
setup.print_puncture_information()
|
|
||||||
|
|
||||||
print("\n Generating AMSS-NCKU input parfile...")
|
|
||||||
numerical_grid.append_AMSSNCKU_cgh_input()
|
|
||||||
|
|
||||||
print("\n Plotting initial grid...")
|
|
||||||
numerical_grid.plot_initial_grid()
|
|
||||||
|
|
||||||
print("\n Generating macro files...")
|
|
||||||
generate_macrodef.generate_macrodef_h()
|
|
||||||
generate_macrodef.generate_macrodef_fh()
|
|
||||||
|
|
||||||
# --- Compilation Preparation ---
|
|
||||||
print("\n Preparing to compile and run...")
|
|
||||||
|
|
||||||
AMSS_NCKU_source_path = "AMSS_NCKU_source"
|
|
||||||
AMSS_NCKU_source_copy = os.path.join(File_directory, "AMSS_NCKU_source_copy")
|
|
||||||
|
|
||||||
if not os.path.exists(AMSS_NCKU_source_path):
|
|
||||||
print(" Error: AMSS_NCKU_source not found! Please run in the project root.")
|
|
||||||
return
|
|
||||||
|
|
||||||
shutil.copytree(AMSS_NCKU_source_path, AMSS_NCKU_source_copy)
|
|
||||||
|
|
||||||
macrodef_h_path = os.path.join(File_directory, "macrodef.h")
|
|
||||||
macrodef_fh_path = os.path.join(File_directory, "macrodef.fh")
|
|
||||||
|
|
||||||
shutil.copy2(macrodef_h_path, AMSS_NCKU_source_copy)
|
|
||||||
shutil.copy2(macrodef_fh_path, AMSS_NCKU_source_copy)
|
|
||||||
|
|
||||||
# --- Compilation ---
|
|
||||||
cwd = os.getcwd()
|
|
||||||
os.chdir(AMSS_NCKU_source_copy)
|
|
||||||
|
|
||||||
print(" Compiling ABE...")
|
|
||||||
makefile_and_run.makefile_ABE()
|
|
||||||
|
|
||||||
if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
|
|
||||||
print(" Compiling TwoPunctureABE...")
|
|
||||||
makefile_and_run.makefile_TwoPunctureABE()
|
|
||||||
|
|
||||||
os.chdir(cwd)
|
|
||||||
|
|
||||||
# --- Copy Executables ---
|
|
||||||
if (input_data.GPU_Calculation == "no"):
|
|
||||||
ABE_file = os.path.join(AMSS_NCKU_source_copy, "ABE")
|
|
||||||
else:
|
|
||||||
ABE_file = os.path.join(AMSS_NCKU_source_copy, "ABEGPU")
|
|
||||||
|
|
||||||
if not os.path.exists(ABE_file):
|
|
||||||
print(" Error: ABE executable compilation failed.")
|
|
||||||
return
|
|
||||||
|
|
||||||
shutil.copy2(ABE_file, output_directory)
|
|
||||||
|
|
||||||
TwoPuncture_file = os.path.join(AMSS_NCKU_source_copy, "TwoPunctureABE")
|
|
||||||
if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
|
|
||||||
if not os.path.exists(TwoPuncture_file):
|
|
||||||
print(" Error: TwoPunctureABE compilation failed.")
|
|
||||||
return
|
|
||||||
shutil.copy2(TwoPuncture_file, output_directory)
|
|
||||||
|
|
||||||
# --- Execution ---
|
|
||||||
start_time = time.time()
|
|
||||||
|
|
||||||
if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
|
|
||||||
print("\n Generating TwoPuncture input...")
|
|
||||||
generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input()
|
|
||||||
|
|
||||||
AMSS_NCKU_TwoPuncture_inputfile = 'AMSS-NCKU-TwoPuncture.input'
|
|
||||||
AMSS_NCKU_TwoPuncture_inputfile_path = os.path.join( File_directory, AMSS_NCKU_TwoPuncture_inputfile )
|
|
||||||
shutil.copy2( AMSS_NCKU_TwoPuncture_inputfile_path, os.path.join(output_directory, 'TwoPunctureinput.par') )
|
|
||||||
|
|
||||||
print(" Running TwoPunctureABE...")
|
|
||||||
os.chdir(output_directory)
|
|
||||||
makefile_and_run.run_TwoPunctureABE()
|
|
||||||
os.chdir(cwd)
|
|
||||||
|
|
||||||
# Update Puncture Parameter
|
|
||||||
renew_puncture_parameter.append_AMSSNCKU_BSSN_input(File_directory, output_directory)
|
|
||||||
|
|
||||||
AMSS_NCKU_inputfile = 'AMSS-NCKU.input'
|
|
||||||
AMSS_NCKU_inputfile_path = os.path.join(File_directory, AMSS_NCKU_inputfile)
|
|
||||||
shutil.copy2( AMSS_NCKU_inputfile_path, os.path.join(output_directory, 'input.par') )
|
|
||||||
|
|
||||||
print("\n Input files ready. Launching ABE...")
|
|
||||||
|
|
||||||
os.chdir(output_directory)
|
|
||||||
makefile_and_run.run_ABE()
|
|
||||||
os.chdir(cwd)
|
|
||||||
|
|
||||||
end_time = time.time()
|
|
||||||
elapsed_time = end_time - start_time
|
|
||||||
|
|
||||||
# --- Post-processing ---
|
|
||||||
print("\n Copying output files for inspection...")
|
|
||||||
AMSS_NCKU_error_file_path = os.path.join(binary_results_directory, "setting.par")
|
|
||||||
if os.path.exists(AMSS_NCKU_error_file_path):
|
|
||||||
shutil.copy( AMSS_NCKU_error_file_path, os.path.join(output_directory, "AMSSNCKU_setting_parameter") )
|
|
||||||
|
|
||||||
AMSS_NCKU_error_file_path = os.path.join(binary_results_directory, "Error.log")
|
|
||||||
if os.path.exists(AMSS_NCKU_error_file_path):
|
|
||||||
shutil.copy( AMSS_NCKU_error_file_path, os.path.join(output_directory, "Error.log") )
|
|
||||||
|
|
||||||
for fname in ["bssn_BH.dat", "bssn_ADMQs.dat", "bssn_psi4.dat", "bssn_constraint.dat"]:
|
|
||||||
fpath = os.path.join(binary_results_directory, fname)
|
|
||||||
if os.path.exists(fpath):
|
|
||||||
shutil.copy(fpath, os.path.join(output_directory, fname))
|
|
||||||
|
|
||||||
# --- Plotting ---
|
|
||||||
print("\n Plotting results...")
|
|
||||||
try:
|
|
||||||
plot_xiaoqu.generate_puncture_orbit_plot( binary_results_directory, figure_directory )
|
|
||||||
plot_xiaoqu.generate_puncture_orbit_plot3D( binary_results_directory, figure_directory )
|
|
||||||
plot_xiaoqu.generate_puncture_distence_plot( binary_results_directory, figure_directory )
|
|
||||||
|
|
||||||
for i in range(input_data.Detector_Number):
|
|
||||||
plot_xiaoqu.generate_gravitational_wave_psi4_plot( binary_results_directory, figure_directory, i )
|
|
||||||
plot_GW_strain_amplitude_xiaoqu.generate_gravitational_wave_amplitude_plot( binary_results_directory, figure_directory, i )
|
|
||||||
|
|
||||||
for i in range(input_data.Detector_Number):
|
|
||||||
plot_xiaoqu.generate_ADMmass_plot( binary_results_directory, figure_directory, i )
|
|
||||||
|
|
||||||
for i in range(input_data.grid_level):
|
|
||||||
plot_xiaoqu.generate_constraint_check_plot( binary_results_directory, figure_directory, i )
|
|
||||||
|
|
||||||
plot_xiaoqu.generate_binary_data_plot( binary_results_directory, figure_directory )
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Warning: Plotting failed: {e}")
|
|
||||||
|
|
||||||
print(f"\n Program Cost = {elapsed_time:.2f} Seconds \n")
|
|
||||||
print(" AMSS-NCKU-Python simulation finished (Mini Test).\n")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -277,3 +277,4 @@ def main():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
@@ -37,51 +37,57 @@ close(77)
|
|||||||
end program checkFFT
|
end program checkFFT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
!-------------
|
|
||||||
! Optimized FFT using Intel oneMKL DFTI
|
|
||||||
! Mathematical equivalence: Standard DFT definition
|
|
||||||
! Forward (isign=1): X[k] = sum_{n=0}^{N-1} x[n] * exp(-2*pi*i*k*n/N)
|
|
||||||
! Backward (isign=-1): X[k] = sum_{n=0}^{N-1} x[n] * exp(+2*pi*i*k*n/N)
|
|
||||||
! Input/Output: dataa is interleaved complex array [Re(0),Im(0),Re(1),Im(1),...]
|
|
||||||
!-------------
|
!-------------
|
||||||
SUBROUTINE four1(dataa,nn,isign)
|
SUBROUTINE four1(dataa,nn,isign)
|
||||||
use MKL_DFTI
|
|
||||||
implicit none
|
implicit none
|
||||||
INTEGER, intent(in) :: isign, nn
|
INTEGER::isign,nn
|
||||||
DOUBLE PRECISION, dimension(2*nn), intent(inout) :: dataa
|
double precision,dimension(2*nn)::dataa
|
||||||
|
INTEGER::i,istep,j,m,mmax,n
|
||||||
type(DFTI_DESCRIPTOR), pointer :: desc
|
double precision::tempi,tempr
|
||||||
integer :: status
|
DOUBLE PRECISION::theta,wi,wpi,wpr,wr,wtemp
|
||||||
|
n=2*nn
|
||||||
! Create DFTI descriptor for 1D complex-to-complex transform
|
j=1
|
||||||
status = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 1, nn)
|
do i=1,n,2
|
||||||
if (status /= 0) return
|
if(j.gt.i)then
|
||||||
|
tempr=dataa(j)
|
||||||
! Set input/output storage as interleaved complex (default)
|
tempi=dataa(j+1)
|
||||||
status = DftiSetValue(desc, DFTI_PLACEMENT, DFTI_INPLACE)
|
dataa(j)=dataa(i)
|
||||||
if (status /= 0) then
|
dataa(j+1)=dataa(i+1)
|
||||||
status = DftiFreeDescriptor(desc)
|
dataa(i)=tempr
|
||||||
return
|
dataa(i+1)=tempi
|
||||||
|
endif
|
||||||
|
m=nn
|
||||||
|
1 if ((m.ge.2).and.(j.gt.m)) then
|
||||||
|
j=j-m
|
||||||
|
m=m/2
|
||||||
|
goto 1
|
||||||
|
endif
|
||||||
|
j=j+m
|
||||||
|
enddo
|
||||||
|
mmax=2
|
||||||
|
2 if (n.gt.mmax) then
|
||||||
|
istep=2*mmax
|
||||||
|
theta=6.28318530717959d0/(isign*mmax)
|
||||||
|
wpr=-2.d0*sin(0.5d0*theta)**2
|
||||||
|
wpi=sin(theta)
|
||||||
|
wr=1.d0
|
||||||
|
wi=0.d0
|
||||||
|
do m=1,mmax,2
|
||||||
|
do i=m,n,istep
|
||||||
|
j=i+mmax
|
||||||
|
tempr=sngl(wr)*dataa(j)-sngl(wi)*dataa(j+1)
|
||||||
|
tempi=sngl(wr)*dataa(j+1)+sngl(wi)*dataa(j)
|
||||||
|
dataa(j)=dataa(i)-tempr
|
||||||
|
dataa(j+1)=dataa(i+1)-tempi
|
||||||
|
dataa(i)=dataa(i)+tempr
|
||||||
|
dataa(i+1)=dataa(i+1)+tempi
|
||||||
|
enddo
|
||||||
|
wtemp=wr
|
||||||
|
wr=wr*wpr-wi*wpi+wr
|
||||||
|
wi=wi*wpr+wtemp*wpi+wi
|
||||||
|
enddo
|
||||||
|
mmax=istep
|
||||||
|
goto 2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
! Commit the descriptor
|
|
||||||
status = DftiCommitDescriptor(desc)
|
|
||||||
if (status /= 0) then
|
|
||||||
status = DftiFreeDescriptor(desc)
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
! Execute FFT based on direction
|
|
||||||
if (isign == 1) then
|
|
||||||
! Forward FFT: exp(-2*pi*i*k*n/N)
|
|
||||||
status = DftiComputeForward(desc, dataa)
|
|
||||||
else
|
|
||||||
! Backward FFT: exp(+2*pi*i*k*n/N)
|
|
||||||
status = DftiComputeBackward(desc, dataa)
|
|
||||||
endif
|
|
||||||
|
|
||||||
! Free descriptor
|
|
||||||
status = DftiFreeDescriptor(desc)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
END SUBROUTINE four1
|
END SUBROUTINE four1
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ using namespace std;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "TwoPunctures.h"
|
#include "TwoPunctures.h"
|
||||||
#include <mkl_cblas.h>
|
|
||||||
|
|
||||||
TwoPunctures::TwoPunctures(double mp, double mm, double b,
|
TwoPunctures::TwoPunctures(double mp, double mm, double b,
|
||||||
double P_plusx, double P_plusy, double P_plusz,
|
double P_plusx, double P_plusy, double P_plusz,
|
||||||
@@ -892,17 +891,25 @@ double TwoPunctures::norm1(double *v, int n)
|
|||||||
/* -------------------------------------------------------------------------*/
|
/* -------------------------------------------------------------------------*/
|
||||||
double TwoPunctures::norm2(double *v, int n)
|
double TwoPunctures::norm2(double *v, int n)
|
||||||
{
|
{
|
||||||
// Optimized with oneMKL BLAS DNRM2
|
int i;
|
||||||
// Computes: sqrt(sum(v[i]^2))
|
double result = 0;
|
||||||
return cblas_dnrm2(n, v, 1);
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
result += v[i] * v[i];
|
||||||
|
|
||||||
|
return sqrt(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------*/
|
/* -------------------------------------------------------------------------*/
|
||||||
double TwoPunctures::scalarproduct(double *v, double *w, int n)
|
double TwoPunctures::scalarproduct(double *v, double *w, int n)
|
||||||
{
|
{
|
||||||
// Optimized with oneMKL BLAS DDOT
|
int i;
|
||||||
// Computes: sum(v[i] * w[i])
|
double result = 0;
|
||||||
return cblas_ddot(n, v, 1, w, 1);
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
result += v[i] * w[i];
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------*/
|
/* -------------------------------------------------------------------------*/
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1117,149 +1117,140 @@ end subroutine d2dump
|
|||||||
!------------------------------------------------------------------------------
|
!------------------------------------------------------------------------------
|
||||||
! Lagrangian polynomial interpolation
|
! Lagrangian polynomial interpolation
|
||||||
!------------------------------------------------------------------------------
|
!------------------------------------------------------------------------------
|
||||||
|
subroutine polint(xa, ya, x, y, dy, ordn)
|
||||||
subroutine polint(xa,ya,x,y,dy,ordn)
|
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
!~~~~~~> Input Parameter:
|
integer, intent(in) :: ordn
|
||||||
integer,intent(in) :: ordn
|
real*8, dimension(ordn), intent(in) :: xa, ya
|
||||||
real*8, dimension(ordn), intent(in) :: xa,ya
|
|
||||||
real*8, intent(in) :: x
|
real*8, intent(in) :: x
|
||||||
real*8, intent(out) :: y,dy
|
real*8, intent(out) :: y, dy
|
||||||
|
|
||||||
!~~~~~~> Other parameter:
|
integer :: i, m, ns, n_m
|
||||||
|
real*8, dimension(ordn) :: c, d, ho
|
||||||
|
real*8 :: dif, dift, hp, h, den_val
|
||||||
|
|
||||||
integer :: m,n,ns
|
! Initialization
|
||||||
real*8, dimension(ordn) :: c,d,den,ho
|
c = ya
|
||||||
real*8 :: dif,dift
|
d = ya
|
||||||
|
ho = xa - x
|
||||||
!~~~~~~>
|
|
||||||
|
ns = 1
|
||||||
n=ordn
|
dif = abs(x - xa(1))
|
||||||
m=ordn
|
|
||||||
|
! Find the index of the closest table entry
|
||||||
c=ya
|
do i = 2, ordn
|
||||||
d=ya
|
dift = abs(x - xa(i))
|
||||||
ho=xa-x
|
if (dift < dif) then
|
||||||
|
ns = i
|
||||||
ns=1
|
dif = dift
|
||||||
dif=abs(x-xa(1))
|
end if
|
||||||
do m=1,n
|
|
||||||
dift=abs(x-xa(m))
|
|
||||||
if(dift < dif) then
|
|
||||||
ns=m
|
|
||||||
dif=dift
|
|
||||||
end if
|
|
||||||
end do
|
end do
|
||||||
|
|
||||||
y=ya(ns)
|
y = ya(ns)
|
||||||
ns=ns-1
|
ns = ns - 1
|
||||||
do m=1,n-1
|
|
||||||
den(1:n-m)=ho(1:n-m)-ho(1+m:n)
|
! Main Neville's algorithm loop
|
||||||
if (any(den(1:n-m) == 0.0))then
|
do m = 1, ordn - 1
|
||||||
write(*,*) 'failure in polint for point',x
|
n_m = ordn - m
|
||||||
write(*,*) 'with input points: ',xa
|
do i = 1, n_m
|
||||||
stop
|
hp = ho(i)
|
||||||
endif
|
h = ho(i+m)
|
||||||
den(1:n-m)=(c(2:n-m+1)-d(1:n-m))/den(1:n-m)
|
den_val = hp - h
|
||||||
d(1:n-m)=ho(1+m:n)*den(1:n-m)
|
|
||||||
c(1:n-m)=ho(1:n-m)*den(1:n-m)
|
! Check for division by zero locally
|
||||||
if (2*ns < n-m) then
|
if (den_val == 0.0d0) then
|
||||||
dy=c(ns+1)
|
write(*,*) 'failure in polint for point',x
|
||||||
|
write(*,*) 'with input points: ',xa
|
||||||
|
stop
|
||||||
|
end if
|
||||||
|
|
||||||
|
! Reuse den_val to avoid redundant divisions
|
||||||
|
den_val = (c(i+1) - d(i)) / den_val
|
||||||
|
|
||||||
|
! Update c and d in place
|
||||||
|
d(i) = h * den_val
|
||||||
|
c(i) = hp * den_val
|
||||||
|
end do
|
||||||
|
|
||||||
|
! Decide which path (up or down the tableau) to take
|
||||||
|
if (2 * ns < n_m) then
|
||||||
|
dy = c(ns + 1)
|
||||||
else
|
else
|
||||||
dy=d(ns)
|
dy = d(ns)
|
||||||
ns=ns-1
|
ns = ns - 1
|
||||||
end if
|
end if
|
||||||
y=y+dy
|
y = y + dy
|
||||||
end do
|
end do
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
end subroutine polint
|
end subroutine polint
|
||||||
!------------------------------------------------------------------------------
|
!------------------------------------------------------------------------------
|
||||||
!
|
!
|
||||||
! interpolation in 2 dimensions, follow yx order
|
! interpolation in 2 dimensions, follow yx order
|
||||||
!
|
!
|
||||||
!------------------------------------------------------------------------------
|
!------------------------------------------------------------------------------
|
||||||
subroutine polin2(x1a,x2a,ya,x1,x2,y,dy,ordn)
|
subroutine polin2(x1a,x2a,ya,x1,x2,y,dy,ordn)
|
||||||
|
implicit none
|
||||||
|
integer,intent(in) :: ordn
|
||||||
|
real*8, dimension(ordn), intent(in) :: x1a,x2a
|
||||||
|
real*8, dimension(ordn,ordn), intent(in) :: ya
|
||||||
|
real*8, intent(in) :: x1,x2
|
||||||
|
real*8, intent(out) :: y,dy
|
||||||
|
|
||||||
implicit none
|
integer :: j
|
||||||
|
real*8, dimension(ordn) :: ymtmp
|
||||||
|
real*8 :: dy_temp ! Local variable to prevent overwriting result
|
||||||
|
|
||||||
!~~~~~~> Input parameters:
|
! Optimized sequence: Loop over columns (j)
|
||||||
integer,intent(in) :: ordn
|
! ya(:,j) is a contiguous memory block in Fortran
|
||||||
real*8, dimension(1:ordn), intent(in) :: x1a,x2a
|
do j=1,ordn
|
||||||
real*8, dimension(1:ordn,1:ordn), intent(in) :: ya
|
call polint(x1a, ya(:,j), x1, ymtmp(j), dy_temp, ordn)
|
||||||
real*8, intent(in) :: x1,x2
|
end do
|
||||||
real*8, intent(out) :: y,dy
|
|
||||||
|
|
||||||
!~~~~~~> Other parameters:
|
! Final interpolation on the results
|
||||||
|
call polint(x2a, ymtmp, x2, y, dy, ordn)
|
||||||
integer :: i,m
|
|
||||||
real*8, dimension(ordn) :: ymtmp
|
|
||||||
real*8, dimension(ordn) :: yntmp
|
|
||||||
|
|
||||||
m=size(x1a)
|
|
||||||
|
|
||||||
do i=1,m
|
|
||||||
|
|
||||||
yntmp=ya(i,:)
|
|
||||||
call polint(x2a,yntmp,x2,ymtmp(i),dy,ordn)
|
|
||||||
|
|
||||||
end do
|
|
||||||
|
|
||||||
call polint(x1a,ymtmp,x1,y,dy,ordn)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
return
|
||||||
end subroutine polin2
|
end subroutine polin2
|
||||||
!------------------------------------------------------------------------------
|
!------------------------------------------------------------------------------
|
||||||
!
|
!
|
||||||
! interpolation in 3 dimensions, follow zyx order
|
! interpolation in 3 dimensions, follow zyx order
|
||||||
!
|
!
|
||||||
!------------------------------------------------------------------------------
|
!------------------------------------------------------------------------------
|
||||||
subroutine polin3(x1a,x2a,x3a,ya,x1,x2,x3,y,dy,ordn)
|
subroutine polin3(x1a,x2a,x3a,ya,x1,x2,x3,y,dy,ordn)
|
||||||
|
implicit none
|
||||||
|
integer,intent(in) :: ordn
|
||||||
|
real*8, dimension(ordn), intent(in) :: x1a,x2a,x3a
|
||||||
|
real*8, dimension(ordn,ordn,ordn), intent(in) :: ya
|
||||||
|
real*8, intent(in) :: x1,x2,x3
|
||||||
|
real*8, intent(out) :: y,dy
|
||||||
|
|
||||||
implicit none
|
integer :: j, k
|
||||||
|
real*8, dimension(ordn,ordn) :: yatmp
|
||||||
|
real*8, dimension(ordn) :: ymtmp
|
||||||
|
real*8 :: dy_temp
|
||||||
|
|
||||||
!~~~~~~> Input parameters:
|
! Sequence change: Process the contiguous first dimension (x1) first.
|
||||||
integer,intent(in) :: ordn
|
! We loop through the 'slow' planes (j, k) to extract 'fast' columns.
|
||||||
real*8, dimension(1:ordn), intent(in) :: x1a,x2a,x3a
|
do k=1,ordn
|
||||||
real*8, dimension(1:ordn,1:ordn,1:ordn), intent(in) :: ya
|
do j=1,ordn
|
||||||
real*8, intent(in) :: x1,x2,x3
|
! ya(:,j,k) is contiguous; much faster than ya(i,j,:)
|
||||||
real*8, intent(out) :: y,dy
|
call polint(x1a, ya(:,j,k), x1, yatmp(j,k), dy_temp, ordn)
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
|
||||||
!~~~~~~> Other parameters:
|
! Now process the second dimension
|
||||||
|
do k=1,ordn
|
||||||
|
call polint(x2a, yatmp(:,k), x2, ymtmp(k), dy_temp, ordn)
|
||||||
|
end do
|
||||||
|
|
||||||
integer :: i,j,m,n
|
! Final dimension
|
||||||
real*8, dimension(ordn,ordn) :: yatmp
|
call polint(x3a, ymtmp, x3, y, dy, ordn)
|
||||||
real*8, dimension(ordn) :: ymtmp
|
|
||||||
real*8, dimension(ordn) :: yntmp
|
|
||||||
real*8, dimension(ordn) :: yqtmp
|
|
||||||
|
|
||||||
m=size(x1a)
|
|
||||||
n=size(x2a)
|
|
||||||
|
|
||||||
do i=1,m
|
|
||||||
do j=1,n
|
|
||||||
|
|
||||||
yqtmp=ya(i,j,:)
|
|
||||||
call polint(x3a,yqtmp,x3,yatmp(i,j),dy,ordn)
|
|
||||||
|
|
||||||
end do
|
|
||||||
|
|
||||||
yntmp=yatmp(i,:)
|
|
||||||
call polint(x2a,yntmp,x2,ymtmp(i),dy,ordn)
|
|
||||||
|
|
||||||
end do
|
|
||||||
|
|
||||||
call polint(x1a,ymtmp,x1,y,dy,ordn)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
return
|
||||||
end subroutine polin3
|
end subroutine polin3
|
||||||
!--------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------
|
||||||
! calculate L2norm
|
! calculate L2norm
|
||||||
subroutine l2normhelper(ex, X, Y, Z,xmin,ymin,zmin,xmax,ymax,zmax,&
|
subroutine l2normhelper(ex, X, Y, Z,xmin,ymin,zmin,xmax,ymax,zmax,&
|
||||||
f,f_out,gw)
|
f,f_out,gw)
|
||||||
|
|
||||||
@@ -1276,9 +1267,7 @@ end subroutine d2dump
|
|||||||
real*8 :: dX, dY, dZ
|
real*8 :: dX, dY, dZ
|
||||||
integer::imin,jmin,kmin
|
integer::imin,jmin,kmin
|
||||||
integer::imax,jmax,kmax
|
integer::imax,jmax,kmax
|
||||||
integer::i,j,k,n_elements
|
integer::i,j,k
|
||||||
real*8, dimension(:), allocatable :: f_flat
|
|
||||||
real*8, external :: DDOT
|
|
||||||
|
|
||||||
dX = X(2) - X(1)
|
dX = X(2) - X(1)
|
||||||
dY = Y(2) - Y(1)
|
dY = Y(2) - Y(1)
|
||||||
@@ -1302,12 +1291,7 @@ if(dabs(X(1)-xmin) < dX) imin = 1
|
|||||||
if(dabs(Y(1)-ymin) < dY) jmin = 1
|
if(dabs(Y(1)-ymin) < dY) jmin = 1
|
||||||
if(dabs(Z(1)-zmin) < dZ) kmin = 1
|
if(dabs(Z(1)-zmin) < dZ) kmin = 1
|
||||||
|
|
||||||
! Optimized with oneMKL BLAS DDOT for dot product
|
f_out = sum(f(imin:imax,jmin:jmax,kmin:kmax)*f(imin:imax,jmin:jmax,kmin:kmax))
|
||||||
n_elements = (imax-imin+1)*(jmax-jmin+1)*(kmax-kmin+1)
|
|
||||||
allocate(f_flat(n_elements))
|
|
||||||
f_flat = reshape(f(imin:imax,jmin:jmax,kmin:kmax), [n_elements])
|
|
||||||
f_out = DDOT(n_elements, f_flat, 1, f_flat, 1)
|
|
||||||
deallocate(f_flat)
|
|
||||||
|
|
||||||
f_out = f_out*dX*dY*dZ
|
f_out = f_out*dX*dY*dZ
|
||||||
|
|
||||||
@@ -1332,9 +1316,7 @@ f_out = f_out*dX*dY*dZ
|
|||||||
real*8 :: dX, dY, dZ
|
real*8 :: dX, dY, dZ
|
||||||
integer::imin,jmin,kmin
|
integer::imin,jmin,kmin
|
||||||
integer::imax,jmax,kmax
|
integer::imax,jmax,kmax
|
||||||
integer::i,j,k,n_elements
|
integer::i,j,k
|
||||||
real*8, dimension(:), allocatable :: f_flat
|
|
||||||
real*8, external :: DDOT
|
|
||||||
|
|
||||||
real*8 :: PIo4
|
real*8 :: PIo4
|
||||||
|
|
||||||
@@ -1397,12 +1379,7 @@ if(Symmetry==2)then
|
|||||||
if(dabs(ymin+gw*dY)<dY.and.Y(1)<0.d0) jmin = gw+1
|
if(dabs(ymin+gw*dY)<dY.and.Y(1)<0.d0) jmin = gw+1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
! Optimized with oneMKL BLAS DDOT for dot product
|
f_out = sum(f(imin:imax,jmin:jmax,kmin:kmax)*f(imin:imax,jmin:jmax,kmin:kmax))
|
||||||
n_elements = (imax-imin+1)*(jmax-jmin+1)*(kmax-kmin+1)
|
|
||||||
allocate(f_flat(n_elements))
|
|
||||||
f_flat = reshape(f(imin:imax,jmin:jmax,kmin:kmax), [n_elements])
|
|
||||||
f_out = DDOT(n_elements, f_flat, 1, f_flat, 1)
|
|
||||||
deallocate(f_flat)
|
|
||||||
|
|
||||||
f_out = f_out*dX*dY*dZ
|
f_out = f_out*dX*dY*dZ
|
||||||
|
|
||||||
@@ -1430,8 +1407,6 @@ f_out = f_out*dX*dY*dZ
|
|||||||
integer::imin,jmin,kmin
|
integer::imin,jmin,kmin
|
||||||
integer::imax,jmax,kmax
|
integer::imax,jmax,kmax
|
||||||
integer::i,j,k
|
integer::i,j,k
|
||||||
real*8, dimension(:), allocatable :: f_flat
|
|
||||||
real*8, external :: DDOT
|
|
||||||
|
|
||||||
real*8 :: PIo4
|
real*8 :: PIo4
|
||||||
|
|
||||||
@@ -1494,12 +1469,11 @@ if(Symmetry==2)then
|
|||||||
if(dabs(ymin+gw*dY)<dY.and.Y(1)<0.d0) jmin = gw+1
|
if(dabs(ymin+gw*dY)<dY.and.Y(1)<0.d0) jmin = gw+1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
! Optimized with oneMKL BLAS DDOT for dot product
|
f_out = sum(f(imin:imax,jmin:jmax,kmin:kmax)*f(imin:imax,jmin:jmax,kmin:kmax))
|
||||||
|
|
||||||
|
f_out = f_out
|
||||||
|
|
||||||
Nout = (imax-imin+1)*(jmax-jmin+1)*(kmax-kmin+1)
|
Nout = (imax-imin+1)*(jmax-jmin+1)*(kmax-kmin+1)
|
||||||
allocate(f_flat(Nout))
|
|
||||||
f_flat = reshape(f(imin:imax,jmin:jmax,kmin:kmax), [Nout])
|
|
||||||
f_out = DDOT(Nout, f_flat, 1, f_flat, 1)
|
|
||||||
deallocate(f_flat)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1697,7 +1671,6 @@ deallocate(f_flat)
|
|||||||
real*8, dimension(ORDN,ORDN) :: tmp2
|
real*8, dimension(ORDN,ORDN) :: tmp2
|
||||||
real*8, dimension(ORDN) :: tmp1
|
real*8, dimension(ORDN) :: tmp1
|
||||||
real*8, dimension(3) :: SoAh
|
real*8, dimension(3) :: SoAh
|
||||||
real*8, external :: DDOT
|
|
||||||
|
|
||||||
! +1 because c++ gives 0 for first point
|
! +1 because c++ gives 0 for first point
|
||||||
cxB = inds+1
|
cxB = inds+1
|
||||||
@@ -1733,21 +1706,20 @@ deallocate(f_flat)
|
|||||||
ya=fh(cxB(1):cxT(1),cxB(2):cxT(2),cxB(3):cxT(3))
|
ya=fh(cxB(1):cxT(1),cxB(2):cxT(2),cxB(3):cxT(3))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
! Optimized with BLAS operations for better performance
|
|
||||||
! First dimension: z-direction weighted sum
|
|
||||||
tmp2=0
|
tmp2=0
|
||||||
do m=1,ORDN
|
do m=1,ORDN
|
||||||
tmp2 = tmp2 + coef(2*ORDN+m)*ya(:,:,m)
|
tmp2 = tmp2 + coef(2*ORDN+m)*ya(:,:,m)
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
! Second dimension: y-direction weighted sum
|
|
||||||
tmp1=0
|
tmp1=0
|
||||||
do m=1,ORDN
|
do m=1,ORDN
|
||||||
tmp1 = tmp1 + coef(ORDN+m)*tmp2(:,m)
|
tmp1 = tmp1 + coef(ORDN+m)*tmp2(:,m)
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
! Third dimension: x-direction weighted sum using BLAS DDOT
|
f_int=0
|
||||||
f_int = DDOT(ORDN, coef(1:ORDN), 1, tmp1, 1)
|
do m=1,ORDN
|
||||||
|
f_int = f_int + coef(m)*tmp1(m)
|
||||||
|
enddo
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1777,7 +1749,6 @@ deallocate(f_flat)
|
|||||||
real*8, dimension(ORDN,ORDN) :: ya
|
real*8, dimension(ORDN,ORDN) :: ya
|
||||||
real*8, dimension(ORDN) :: tmp1
|
real*8, dimension(ORDN) :: tmp1
|
||||||
real*8, dimension(2) :: SoAh
|
real*8, dimension(2) :: SoAh
|
||||||
real*8, external :: DDOT
|
|
||||||
|
|
||||||
! +1 because c++ gives 0 for first point
|
! +1 because c++ gives 0 for first point
|
||||||
cxB = inds(1:2)+1
|
cxB = inds(1:2)+1
|
||||||
@@ -1807,14 +1778,15 @@ deallocate(f_flat)
|
|||||||
ya=fh(cxB(1):cxT(1),cxB(2):cxT(2),inds(3))
|
ya=fh(cxB(1):cxT(1),cxB(2):cxT(2),inds(3))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
! Optimized with BLAS operations
|
|
||||||
tmp1=0
|
tmp1=0
|
||||||
do m=1,ORDN
|
do m=1,ORDN
|
||||||
tmp1 = tmp1 + coef(ORDN+m)*ya(:,m)
|
tmp1 = tmp1 + coef(ORDN+m)*ya(:,m)
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
! Use BLAS DDOT for final weighted sum
|
f_int=0
|
||||||
f_int = DDOT(ORDN, coef(1:ORDN), 1, tmp1, 1)
|
do m=1,ORDN
|
||||||
|
f_int = f_int + coef(m)*tmp1(m)
|
||||||
|
enddo
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1845,7 +1817,6 @@ deallocate(f_flat)
|
|||||||
real*8, dimension(ORDN) :: ya
|
real*8, dimension(ORDN) :: ya
|
||||||
real*8 :: SoAh
|
real*8 :: SoAh
|
||||||
integer,dimension(3) :: inds
|
integer,dimension(3) :: inds
|
||||||
real*8, external :: DDOT
|
|
||||||
|
|
||||||
! +1 because c++ gives 0 for first point
|
! +1 because c++ gives 0 for first point
|
||||||
inds = indsi + 1
|
inds = indsi + 1
|
||||||
@@ -1906,8 +1877,10 @@ deallocate(f_flat)
|
|||||||
write(*,*)"error in global_interpind1d, not recognized dumyd = ",dumyd
|
write(*,*)"error in global_interpind1d, not recognized dumyd = ",dumyd
|
||||||
endif
|
endif
|
||||||
|
|
||||||
! Optimized with BLAS DDOT for weighted sum
|
f_int=0
|
||||||
f_int = DDOT(ORDN, coef, 1, ya, 1)
|
do m=1,ORDN
|
||||||
|
f_int = f_int + coef(m)*ya(m)
|
||||||
|
enddo
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -2139,38 +2112,24 @@ deallocate(f_flat)
|
|||||||
|
|
||||||
end function fWigner_d_function
|
end function fWigner_d_function
|
||||||
!----------------------------------
|
!----------------------------------
|
||||||
! Optimized factorial function using lookup table for small N
|
|
||||||
! and log-gamma for large N to avoid overflow
|
|
||||||
function ffact(N) result(gont)
|
function ffact(N) result(gont)
|
||||||
implicit none
|
implicit none
|
||||||
integer,intent(in) :: N
|
integer,intent(in) :: N
|
||||||
|
|
||||||
real*8 :: gont
|
real*8 :: gont
|
||||||
integer :: i
|
|
||||||
|
|
||||||
! Lookup table for factorials 0! to 20! (precomputed)
|
integer :: i
|
||||||
real*8, parameter, dimension(0:20) :: fact_table = [ &
|
|
||||||
1.d0, 1.d0, 2.d0, 6.d0, 24.d0, 120.d0, 720.d0, 5040.d0, 40320.d0, &
|
|
||||||
362880.d0, 3628800.d0, 39916800.d0, 479001600.d0, 6227020800.d0, &
|
|
||||||
87178291200.d0, 1307674368000.d0, 20922789888000.d0, &
|
|
||||||
355687428096000.d0, 6402373705728000.d0, 121645100408832000.d0, &
|
|
||||||
2432902008176640000.d0 ]
|
|
||||||
|
|
||||||
! sanity check
|
! sanity check
|
||||||
if(N < 0)then
|
if(N < 0)then
|
||||||
write(*,*) "ffact: error input for factorial"
|
write(*,*) "ffact: error input for factorial"
|
||||||
gont = 1.d0
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
! Use lookup table for small N (fast path)
|
gont = 1.d0
|
||||||
if(N <= 20)then
|
do i=1,N
|
||||||
gont = fact_table(N)
|
gont = gont*i
|
||||||
else
|
enddo
|
||||||
! Use log-gamma function for large N: N! = exp(log_gamma(N+1))
|
|
||||||
! This avoids overflow and is computed efficiently
|
|
||||||
gont = exp(log_gamma(dble(N+1)))
|
|
||||||
endif
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -2304,3 +2263,4 @@ subroutine find_maximum(ext,X,Y,Z,fun,val,pos,llb,uub)
|
|||||||
return
|
return
|
||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
|
|||||||
@@ -16,66 +16,115 @@ using namespace std;
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#endif
|
#endif
|
||||||
|
/* Linear equation solution by Gauss-Jordan elimination.
|
||||||
// Intel oneMKL LAPACK interface
|
|
||||||
#include <mkl_lapacke.h>
|
|
||||||
/* Linear equation solution using Intel oneMKL LAPACK.
|
|
||||||
a[0..n-1][0..n-1] is the input matrix. b[0..n-1] is input
|
a[0..n-1][0..n-1] is the input matrix. b[0..n-1] is input
|
||||||
containing the right-hand side vectors. On output a is
|
containing the right-hand side vectors. On output a is
|
||||||
replaced by its matrix inverse, and b is replaced by the
|
replaced by its matrix inverse, and b is replaced by the
|
||||||
corresponding set of solution vectors.
|
corresponding set of solution vectors */
|
||||||
|
|
||||||
Mathematical equivalence:
|
|
||||||
Solves: A * x = b => x = A^(-1) * b
|
|
||||||
Original Gauss-Jordan and LAPACK dgesv/dgetri produce identical results
|
|
||||||
within numerical precision. */
|
|
||||||
|
|
||||||
int gaussj(double *a, double *b, int n)
|
int gaussj(double *a, double *b, int n)
|
||||||
{
|
{
|
||||||
// Allocate pivot array and workspace
|
double swap;
|
||||||
lapack_int *ipiv = new lapack_int[n];
|
|
||||||
lapack_int info;
|
|
||||||
|
|
||||||
// Make a copy of matrix a for solving (dgesv modifies it to LU form)
|
int *indxc, *indxr, *ipiv;
|
||||||
double *a_copy = new double[n * n];
|
indxc = new int[n];
|
||||||
for (int i = 0; i < n * n; i++) {
|
indxr = new int[n];
|
||||||
a_copy[i] = a[i];
|
ipiv = new int[n];
|
||||||
|
|
||||||
|
int i, icol, irow, j, k, l, ll;
|
||||||
|
double big, dum, pivinv, temp;
|
||||||
|
|
||||||
|
for (j = 0; j < n; j++)
|
||||||
|
ipiv[j] = 0;
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
big = 0.0;
|
||||||
|
for (j = 0; j < n; j++)
|
||||||
|
if (ipiv[j] != 1)
|
||||||
|
for (k = 0; k < n; k++)
|
||||||
|
{
|
||||||
|
if (ipiv[k] == 0)
|
||||||
|
{
|
||||||
|
if (fabs(a[j * n + k]) >= big)
|
||||||
|
{
|
||||||
|
big = fabs(a[j * n + k]);
|
||||||
|
irow = j;
|
||||||
|
icol = k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ipiv[k] > 1)
|
||||||
|
{
|
||||||
|
cout << "gaussj: Singular Matrix-1" << endl;
|
||||||
|
for (int ii = 0; ii < n; ii++)
|
||||||
|
{
|
||||||
|
for (int jj = 0; jj < n; jj++)
|
||||||
|
cout << a[ii * n + jj] << " ";
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
return 1; // error return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ipiv[icol] = ipiv[icol] + 1;
|
||||||
|
if (irow != icol)
|
||||||
|
{
|
||||||
|
for (l = 0; l < n; l++)
|
||||||
|
{
|
||||||
|
swap = a[irow * n + l];
|
||||||
|
a[irow * n + l] = a[icol * n + l];
|
||||||
|
a[icol * n + l] = swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
swap = b[irow];
|
||||||
|
b[irow] = b[icol];
|
||||||
|
b[icol] = swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
indxr[i] = irow;
|
||||||
|
indxc[i] = icol;
|
||||||
|
|
||||||
|
if (a[icol * n + icol] == 0.0)
|
||||||
|
{
|
||||||
|
cout << "gaussj: Singular Matrix-2" << endl;
|
||||||
|
for (int ii = 0; ii < n; ii++)
|
||||||
|
{
|
||||||
|
for (int jj = 0; jj < n; jj++)
|
||||||
|
cout << a[ii * n + jj] << " ";
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
return 1; // error return
|
||||||
|
}
|
||||||
|
|
||||||
|
pivinv = 1.0 / a[icol * n + icol];
|
||||||
|
a[icol * n + icol] = 1.0;
|
||||||
|
for (l = 0; l < n; l++)
|
||||||
|
a[icol * n + l] *= pivinv;
|
||||||
|
b[icol] *= pivinv;
|
||||||
|
for (ll = 0; ll < n; ll++)
|
||||||
|
if (ll != icol)
|
||||||
|
{
|
||||||
|
dum = a[ll * n + icol];
|
||||||
|
a[ll * n + icol] = 0.0;
|
||||||
|
for (l = 0; l < n; l++)
|
||||||
|
a[ll * n + l] -= a[icol * n + l] * dum;
|
||||||
|
b[ll] -= b[icol] * dum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1: Solve linear system A*x = b using LU decomposition
|
for (l = n - 1; l >= 0; l--)
|
||||||
// LAPACKE_dgesv uses column-major by default, but we use row-major
|
{
|
||||||
info = LAPACKE_dgesv(LAPACK_ROW_MAJOR, n, 1, a_copy, n, ipiv, b, 1);
|
if (indxr[l] != indxc[l])
|
||||||
|
for (k = 0; k < n; k++)
|
||||||
if (info != 0) {
|
{
|
||||||
cout << "gaussj: Singular Matrix (dgesv info=" << info << ")" << endl;
|
swap = a[k * n + indxr[l]];
|
||||||
delete[] ipiv;
|
a[k * n + indxr[l]] = a[k * n + indxc[l]];
|
||||||
delete[] a_copy;
|
a[k * n + indxc[l]] = swap;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Step 2: Compute matrix inverse A^(-1) using LU factorization
|
|
||||||
// First do LU factorization of original matrix a
|
|
||||||
info = LAPACKE_dgetrf(LAPACK_ROW_MAJOR, n, n, a, n, ipiv);
|
|
||||||
|
|
||||||
if (info != 0) {
|
|
||||||
cout << "gaussj: Singular Matrix (dgetrf info=" << info << ")" << endl;
|
|
||||||
delete[] ipiv;
|
|
||||||
delete[] a_copy;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then compute inverse from LU factorization
|
|
||||||
info = LAPACKE_dgetri(LAPACK_ROW_MAJOR, n, a, n, ipiv);
|
|
||||||
|
|
||||||
if (info != 0) {
|
|
||||||
cout << "gaussj: Singular Matrix (dgetri info=" << info << ")" << endl;
|
|
||||||
delete[] ipiv;
|
|
||||||
delete[] a_copy;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] indxc;
|
||||||
|
delete[] indxr;
|
||||||
delete[] ipiv;
|
delete[] ipiv;
|
||||||
delete[] a_copy;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -512,10 +512,11 @@
|
|||||||
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
|
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
|
||||||
DIMENSION V(N),W(N)
|
DIMENSION V(N),W(N)
|
||||||
! SUBROUTINE TO COMPUTE DOUBLE PRECISION VECTOR DOT PRODUCT.
|
! SUBROUTINE TO COMPUTE DOUBLE PRECISION VECTOR DOT PRODUCT.
|
||||||
! Optimized using Intel oneMKL BLAS ddot
|
|
||||||
! Mathematical equivalence: DGVV = sum_{i=1}^{N} V(i)*W(i)
|
|
||||||
|
|
||||||
DOUBLE PRECISION, EXTERNAL :: DDOT
|
SUM = 0.0D0
|
||||||
DGVV = DDOT(N, V, 1, W, 1)
|
DO 10 I = 1,N
|
||||||
|
SUM = SUM + V(I)*W(I)
|
||||||
|
10 CONTINUE
|
||||||
|
DGVV = SUM
|
||||||
RETURN
|
RETURN
|
||||||
END
|
END
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#ifndef MICRODEF_H
|
#ifndef MICRODEF_H
|
||||||
#define MICRODEF_H
|
#define MICRODEF_H
|
||||||
|
|
||||||
#include "macrodef.fh"
|
#include "microdef.fh"
|
||||||
|
|
||||||
// application parameters
|
// application parameters
|
||||||
|
|
||||||
|
|||||||
@@ -30,3 +30,4 @@ Cu = nvcc
|
|||||||
CUDA_LIB_PATH = -L/usr/lib/cuda/lib64 -I/usr/include -I/usr/lib/cuda/include
|
CUDA_LIB_PATH = -L/usr/lib/cuda/lib64 -I/usr/include -I/usr/lib/cuda/include
|
||||||
#CUDA_APP_FLAGS = -c -g -O3 --ptxas-options=-v -arch compute_13 -code compute_13,sm_13 -Dfortran3 -Dnewc
|
#CUDA_APP_FLAGS = -c -g -O3 --ptxas-options=-v -arch compute_13 -code compute_13,sm_13 -Dfortran3 -Dnewc
|
||||||
CUDA_APP_FLAGS = -c -g -O3 --ptxas-options=-v -Dfortran3 -Dnewc
|
CUDA_APP_FLAGS = -c -g -O3 --ptxas-options=-v -Dfortran3 -Dnewc
|
||||||
|
|
||||||
|
|||||||
@@ -392,17 +392,6 @@ def generate_macrodef_fh():
|
|||||||
print( "# Finite_Difference_Method #define ghost_width setting error!!!", file=file1 )
|
print( "# Finite_Difference_Method #define ghost_width setting error!!!", file=file1 )
|
||||||
print( file=file1 )
|
print( file=file1 )
|
||||||
|
|
||||||
# Define macro DEBUG_NAN_CHECK
|
|
||||||
# 0: off (default), 1: on
|
|
||||||
|
|
||||||
debug_nan_check = getattr(input_data, "Debug_NaN_Check", 0)
|
|
||||||
if debug_nan_check:
|
|
||||||
print( "#define DEBUG_NAN_CHECK 1", file=file1 )
|
|
||||||
print( file=file1 )
|
|
||||||
else:
|
|
||||||
print( "#define DEBUG_NAN_CHECK 0", file=file1 )
|
|
||||||
print( file=file1 )
|
|
||||||
|
|
||||||
# Whether to use a shell-patch grid
|
# Whether to use a shell-patch grid
|
||||||
# use shell or not
|
# use shell or not
|
||||||
|
|
||||||
@@ -525,9 +514,6 @@ def generate_macrodef_fh():
|
|||||||
print( " 6th order: 4", file=file1 )
|
print( " 6th order: 4", file=file1 )
|
||||||
print( " 8th order: 5", file=file1 )
|
print( " 8th order: 5", file=file1 )
|
||||||
print( file=file1 )
|
print( file=file1 )
|
||||||
print( "define DEBUG_NAN_CHECK", file=file1 )
|
|
||||||
print( " 0: off (default), 1: on", file=file1 )
|
|
||||||
print( file=file1 )
|
|
||||||
print( "define WithShell", file=file1 )
|
print( "define WithShell", file=file1 )
|
||||||
print( " use shell or not", file=file1 )
|
print( " use shell or not", file=file1 )
|
||||||
print( file=file1 )
|
print( file=file1 )
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ Equation_Class = "BSSN" ## Evolution Equation: choose
|
|||||||
## If "BSSN-EScalar" is chosen, it is necessary to set other parameters below
|
## If "BSSN-EScalar" is chosen, it is necessary to set other parameters below
|
||||||
Initial_Data_Method = "Ansorg-TwoPuncture" ## initial data method: choose "Ansorg-TwoPuncture", "Lousto-Analytical", "Cao-Analytical", "KerrSchild-Analytical"
|
Initial_Data_Method = "Ansorg-TwoPuncture" ## initial data method: choose "Ansorg-TwoPuncture", "Lousto-Analytical", "Cao-Analytical", "KerrSchild-Analytical"
|
||||||
Time_Evolution_Method = "runge-kutta-45" ## time evolution method: choose "runge-kutta-45"
|
Time_Evolution_Method = "runge-kutta-45" ## time evolution method: choose "runge-kutta-45"
|
||||||
Finite_Diffenence_Method = "4th-order" ## finite-difference method: choose "2nd-order", "4th-order", "6th-order", "8th-order"
|
Finite_Diffenence_Method = "4th-order" ## finite-difference method: choose "2nd-order", "4th-order", "6th-order", "8th-order"
|
||||||
Debug_NaN_Check = 0 ## enable NaN checks in compute_rhs_bssn: 0 (off) or 1 (on)
|
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
|
|||||||
@@ -11,18 +11,6 @@
|
|||||||
import AMSS_NCKU_Input as input_data
|
import AMSS_NCKU_Input as input_data
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
## CPU core binding configuration using taskset
|
|
||||||
## taskset ensures all child processes inherit the CPU affinity mask
|
|
||||||
## This forces make and all compiler processes to use only nohz_full cores (4-55, 60-111)
|
|
||||||
## Format: taskset -c 4-55,60-111 ensures processes only run on these cores
|
|
||||||
#NUMACTL_CPU_BIND = "taskset -c 4-55,60-111"
|
|
||||||
NUMACTL_CPU_BIND = ""
|
|
||||||
|
|
||||||
## Build parallelism configuration
|
|
||||||
## Use nohz_full cores (4-55, 60-111) for compilation: 52 + 52 = 104 cores
|
|
||||||
## Set make -j to utilize available cores for faster builds
|
|
||||||
BUILD_JOBS = 14
|
|
||||||
|
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
@@ -38,11 +26,11 @@ def makefile_ABE():
|
|||||||
print( " Compiling the AMSS-NCKU executable file ABE/ABEGPU " )
|
print( " Compiling the AMSS-NCKU executable file ABE/ABEGPU " )
|
||||||
print( )
|
print( )
|
||||||
|
|
||||||
## Build command with CPU binding to nohz_full cores
|
## Build command
|
||||||
if (input_data.GPU_Calculation == "no"):
|
if (input_data.GPU_Calculation == "no"):
|
||||||
makefile_command = f"{NUMACTL_CPU_BIND} make -j{BUILD_JOBS} ABE"
|
makefile_command = "make -j4" + " ABE"
|
||||||
elif (input_data.GPU_Calculation == "yes"):
|
elif (input_data.GPU_Calculation == "yes"):
|
||||||
makefile_command = f"{NUMACTL_CPU_BIND} make -j{BUILD_JOBS} ABEGPU"
|
makefile_command = "make -j4" + " ABEGPU"
|
||||||
else:
|
else:
|
||||||
print( " CPU/GPU numerical calculation setting is wrong " )
|
print( " CPU/GPU numerical calculation setting is wrong " )
|
||||||
print( )
|
print( )
|
||||||
@@ -79,8 +67,8 @@ def makefile_TwoPunctureABE():
|
|||||||
print( " Compiling the AMSS-NCKU executable file TwoPunctureABE " )
|
print( " Compiling the AMSS-NCKU executable file TwoPunctureABE " )
|
||||||
print( )
|
print( )
|
||||||
|
|
||||||
## Build command with CPU binding to nohz_full cores
|
## Build command
|
||||||
makefile_command = f"{NUMACTL_CPU_BIND} make -j{BUILD_JOBS} TwoPunctureABE"
|
makefile_command = "make" + " TwoPunctureABE"
|
||||||
|
|
||||||
## Execute the command with subprocess.Popen and stream output
|
## Execute the command with subprocess.Popen and stream output
|
||||||
makefile_process = subprocess.Popen(makefile_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
makefile_process = subprocess.Popen(makefile_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
||||||
@@ -117,10 +105,10 @@ def run_ABE():
|
|||||||
## Define the command to run; cast other values to strings as needed
|
## Define the command to run; cast other values to strings as needed
|
||||||
|
|
||||||
if (input_data.GPU_Calculation == "no"):
|
if (input_data.GPU_Calculation == "no"):
|
||||||
mpi_command = NUMACTL_CPU_BIND + " mpirun -np " + str(input_data.MPI_processes) + " ./ABE"
|
mpi_command = "mpirun -np " + str(input_data.MPI_processes) + " ./ABE"
|
||||||
mpi_command_outfile = "ABE_out.log"
|
mpi_command_outfile = "ABE_out.log"
|
||||||
elif (input_data.GPU_Calculation == "yes"):
|
elif (input_data.GPU_Calculation == "yes"):
|
||||||
mpi_command = NUMACTL_CPU_BIND + " mpirun -np " + str(input_data.MPI_processes) + " ./ABEGPU"
|
mpi_command = "mpirun -np " + str(input_data.MPI_processes) + " ./ABEGPU"
|
||||||
mpi_command_outfile = "ABEGPU_out.log"
|
mpi_command_outfile = "ABEGPU_out.log"
|
||||||
|
|
||||||
## Execute the MPI command and stream output
|
## Execute the MPI command and stream output
|
||||||
@@ -159,7 +147,7 @@ def run_TwoPunctureABE():
|
|||||||
print( )
|
print( )
|
||||||
|
|
||||||
## Define the command to run
|
## Define the command to run
|
||||||
TwoPuncture_command = NUMACTL_CPU_BIND + " ./TwoPunctureABE"
|
TwoPuncture_command = "./TwoPunctureABE"
|
||||||
TwoPuncture_command_outfile = "TwoPunctureABE_out.log"
|
TwoPuncture_command_outfile = "TwoPunctureABE_out.log"
|
||||||
|
|
||||||
## Execute the command with subprocess.Popen and stream output
|
## Execute the command with subprocess.Popen and stream output
|
||||||
|
|||||||
Reference in New Issue
Block a user