diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f66300 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +__pycache__/ +*.pyc +*.egg-info/ +log.lammps +log_*.lammps +*.data +*.dump +amorphous_*/ +quartz*/ +heatofimmersion*/ +Q4*/ +seed.txt diff --git a/examples/generate_amorphous_system.py b/examples/generate_amorphous_system.py index 5964f3a..3c84f05 100644 --- a/examples/generate_amorphous_system.py +++ b/examples/generate_amorphous_system.py @@ -1,15 +1,19 @@ from interface_builder import Silica +import os # Generate 10 sample of silica surface! for indx in range(2): # prepare the surface + output_folder = f'amorphous_{indx}' + os.makedirs(output_folder, exist_ok=True) + silica_params = { 'lx' : 4, 'ly' : 4, 'lz' : 4, 'vacuum' : 30, 'filename' : 'silica_amorphous.data', - 'output_folder' : f'amorphous_{indx}', + 'output_folder' : output_folder, 'input_folder' : 'test', 'sio2_potential' : './data/SiO2.vashishta', 'sio2_h2o_potential' : "./data/SiOH2O_199_16_adjusted.vashishta", @@ -19,7 +23,7 @@ # initilize the silica system silica = Silica(**silica_params) - silica_file = silica.build_amorphous(16, "lmp", run=True) + silica_file = silica.build_amorphous(mpirun_n=16, lmp_exec="lmp", run=True) # silica_surface = silica.resize_z(silica_file, 90, "silica_surface.data") # silica_annealed = silica.anneal(silica_surface, mpirun_n=16, lmp_exec="lmp", run=True) diff --git a/examples/test_quartz.py b/examples/test_quartz.py index 2c8de95..6debe8c 100644 --- a/examples/test_quartz.py +++ b/examples/test_quartz.py @@ -32,7 +32,7 @@ passivated_silica = silica_thermalize for _ in range(3): passivated_silica = silica.passivate(passivated_silica , T, 'passivated_quartz.data', - thickness=5, mpirun_n=16, lmp_exec='lmp_usc', run=False) + water_thickness=5, mpirun_n=16, lmp_exec='lmp_usc', run=False) silica_passivated_thermalize = silica.thermalize_passivated(passivated_silica, time=50, temp=300, output_filename= "silica_passivated_thermalize.data", diff --git a/interface_builder/__pycache__/__init__.cpython-311.pyc b/interface_builder/__pycache__/__init__.cpython-311.pyc deleted file mode 100644 index 88628fc..0000000 Binary files a/interface_builder/__pycache__/__init__.cpython-311.pyc and /dev/null differ diff --git a/interface_builder/__pycache__/interface_builder.cpython-311.pyc b/interface_builder/__pycache__/interface_builder.cpython-311.pyc deleted file mode 100644 index a4cca86..0000000 Binary files a/interface_builder/__pycache__/interface_builder.cpython-311.pyc and /dev/null differ diff --git a/interface_builder/interface_builder.py b/interface_builder/interface_builder.py index baa65f6..5373079 100644 --- a/interface_builder/interface_builder.py +++ b/interface_builder/interface_builder.py @@ -73,7 +73,8 @@ def __init__( self.sio2_h2o_potential = sio2_h2o_potential # create the output directory - os.system(f'mkdir {output_folder}') + if output_folder: + os.makedirs(output_folder, exist_ok=True) if lx is None and ly is None and lz is None: # copy the input file into the working directory shutil.copyfile( @@ -459,9 +460,6 @@ def set_silanol( 'potential_filename': self.sio2_h2o_potential, 'output_folder': self.output_folder } - lmp_exec = os.path.join( - "/home/users/anthonca/silica-water-interface_sandbox/interface_builder/interface_builder/lmp_exec/", - "lmp") if run: script_path = os.path.join(script_dir, 'script', 'in.set_silanol') self.execute_lammps( @@ -542,7 +540,8 @@ def execute_lammps( mpirun_n=4, lmp_exec='lmp', script=None, - slurm=False): + slurm=False, + oversubscribe=True): '''Execute a LAMMPS simulation with the given arguments. This method executes a LAMMPS simulation using the specified LAMMPS executable and input script, along with additional arguments provided in the lmps_args dictionary. @@ -556,6 +555,8 @@ def execute_lammps( :type script: str or None :param slurm: (Optional) If True, run the simulation using Slurm on a HPC cluster. Default is False. :type slurm: bool + :param oversubscribe: (Optional) If True, run mpirun with --oversubscribe. Default is True. + :type oversubscribe: bool :return: None ''' @@ -573,8 +574,11 @@ def execute_lammps( **lmps_args) sim.run(computer=computer) else: + mpi_args = f"-n {mpirun_n}" + if oversubscribe: + mpi_args += " --oversubscribe" os.system( - f"mpirun -n {mpirun_n} {lmp_exec} -in {script} {lmps_args_list}") + f"mpirun {mpi_args} {lmp_exec} -in {script} {lmps_args_list}") def add_water( self, diff --git a/interface_builder/script/in.passivated_thermalized b/interface_builder/script/in.passivated_thermalized index 94ddd1a..5a49abc 100644 --- a/interface_builder/script/in.passivated_thermalized +++ b/interface_builder/script/in.passivated_thermalized @@ -2,10 +2,10 @@ units metal boundary p p p atom_style atomic -read_data /Users/anthonca/Documents/PhD/silica-water-sim/contact_angle-amorphous/data/new_set/passivation/data/WCA_system_clean/system2_87SiOH_6436.data +read_data ${input_filename} pair_style usc -pair_coeff * * ./data/SiOH2O_nm_0_0.vashishta H O Si +pair_coeff * * ${potential_filename} H O Si pair_modify coord 2 3 2.0 0.3 pair_modify coord 2 1 1.4 0.3 mass 1 1.00794 @@ -27,7 +27,7 @@ variable thermalising_time equal 5 # ps variable thermalising_steps equal ${thermalising_time}/${dt} fix 1 all nvt temp 300 300 $(100*dt) -dump silica all custom 100 ./data/silica-passivated.dump id type x y z +dump silica all custom 100 ${output_folder}/silica-passivated.dump id type x y z log log_passivated-thermalized.lammps thermo_style custom step time temp etotal spcpu cpuremain @@ -36,4 +36,4 @@ thermo 10 timestep ${dt} run ${thermalising_steps} -write_data ./data/passivated-system2_thermalized.data +write_data ${output_filename} diff --git a/setup.py b/setup.py index 1fe5554..907820e 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,9 @@ packages=find_packages(), install_requires=[ "numpy", - "molecular-builder" + "molecular-builder", + "lammps-logfile", + "pandas" ], classifiers=[ "Programming Language :: Python :: 3.9",