2727from __future__ import annotations
2828
2929import ast
30+ import json
3031import shutil
3132from configparser import ConfigParser
3233from pathlib import Path
@@ -64,7 +65,7 @@ def create_gnrs_submit_script(
6465 gnrs_config: Genarris configuration containing execution parameters:
6566 - mpi_launcher: MPI command to use (default: "mpirun")
6667 - python_cmd: Python executable path (default: "python")
67- - genarris_script : Genarris main script name (default: "genarris_master .py")
68+ - genarris_cli : Genarris main script name (default: "genarris_cli .py")
6869 genarris_slurm_config: SLURM resource allocation parameters
6970 single_gnrs_folder: Directory where the SLURM script will be created
7071
@@ -83,7 +84,7 @@ def create_gnrs_submit_script(
8384export OMP_NUM_THREADS=1
8485
8586{ gnrs_config .get ("mpi_launcher" , "mpirun" )} -np { genarris_slurm_config .get ("nodes" , 1 ) * genarris_slurm_config ["ntasks-per-node" ]} \\
86- { gnrs_config .get ("python_cmd" , "python" )} { gnrs_config .get ("genarris_script " , "genarris_master .py" )} { single_gnrs_folder } /ui.conf > { single_gnrs_folder } /Genarris.out
87+ { gnrs_config .get ("python_cmd" , "python" )} { gnrs_config .get ("genarris_cli " , "cli .py" )} --config { single_gnrs_folder } /ui.conf > { single_gnrs_folder } /Genarris.out
8788"""
8889
8990 with open (single_gnrs_folder / "slurm.sh" , "w" ) as f :
@@ -96,7 +97,7 @@ def create_gnrs_config(
9697 mol_name : str ,
9798 geometry_path : str | Path ,
9899 num_structures : int ,
99- spg_info : str ,
100+ spg_distribution_type : str | list [ int ] ,
100101 Z : int ,
101102):
102103 """
@@ -112,7 +113,7 @@ def create_gnrs_config(
112113 mol_name: Identifier for the molecule being processed
113114 geometry_path: Path to the molecular geometry file (XYZ, SDF, etc.)
114115 num_structures: Number of crystal structures to generate
115- spg_info : Space group specification (number or list or "standard" )
116+ spg_distribution_type : Space group distribution type ("standard" or custom list[int] )
116117 Z: Number of molecules per unit cell (Z-value)
117118
118119 Side Effects:
@@ -123,10 +124,10 @@ def create_gnrs_config(
123124 config .read_file (config_file )
124125
125126 config ["master" ]["name" ] = mol_name
126- config ["master" ]["molecule_path" ] = str (geometry_path )
127+ config ["master" ]["molecule_path" ] = json . dumps ([ str (geometry_path )] )
127128 config ["master" ]["Z" ] = str (Z )
128129 config ["generation" ]["num_structures_per_spg" ] = str (num_structures )
129- config ["generation" ]["spg_distribution_type" ] = spg_info
130+ config ["generation" ]["spg_distribution_type" ] = spg_distribution_type
130131
131132 with open (output_dir / "ui.conf" , "w" ) as f :
132133 config .write (f )
@@ -143,9 +144,11 @@ def create_genarris_jobs(
143144 logger = get_central_logger ()
144145 logger .info (f"Starting Genarris generation for { mol_info ['name' ]} " )
145146
146- gnrs_base_config = gnrs_config .get ("base_config " )
147+ gnrs_base_config = gnrs_config .get ("genarris_base_config " )
147148 if gnrs_base_config is None :
148- raise KeyError ("Genarris 'base_config' section is missing in the config file." )
149+ raise KeyError (
150+ "Genarris 'genarris_base_config' section is missing in the config file."
151+ )
149152 logger .info (f"Using Genarris base configuration: { gnrs_base_config } " )
150153
151154 # Parameters for each Genarris run
@@ -159,24 +162,24 @@ def create_genarris_jobs(
159162
160163 z_list = [str (z ) for z in gnrs_vars .get ("Z" , [1 ])]
161164 num_structures_per_spg = gnrs_vars .get ("num_structures_per_spg" , 500 )
162- spg_info = gnrs_vars .get ("spg_info " , "standard" )
165+ spg_distribution_type = gnrs_vars .get ("spg_distribution_type " , "standard" )
163166
164167 # molecule specific spg and z_list info from csv file if provided
165168 # mol_info["z"] is a list of z_values
166169 # mol_info["spg"] is a list of lists of spg values that correspond to each z_value
167170 if gnrs_vars .get ("read_z_from_file" , False ):
168171 z_list = [str (z ) for z in ast .literal_eval (mol_info ["z" ])]
169172 if gnrs_vars .get ("read_spg_from_file" , False ):
170- spg_info = ast .literal_eval (mol_info ["spg" ])
171- if spg_info == "standard" :
172- spg_info = ["standard" ] * len (z_list )
173- if isinstance (spg_info [0 ], int ):
174- spg_info = [spg_info ]
175- if len (spg_info ) == 1 and len (z_list ) > 1 :
176- spg_info = spg_info * len (z_list )
177- if len (spg_info ) != len (z_list ):
173+ spg_distribution_type = ast .literal_eval (mol_info ["spg" ])
174+ if spg_distribution_type == "standard" :
175+ spg_distribution_type = ["standard" ] * len (z_list )
176+ if isinstance (spg_distribution_type [0 ], int ):
177+ spg_distribution_type = [spg_distribution_type ]
178+ if len (spg_distribution_type ) == 1 and len (z_list ) > 1 :
179+ spg_distribution_type = spg_distribution_type * len (z_list )
180+ if len (spg_distribution_type ) != len (z_list ):
178181 raise ValueError (
179- f"Length of spg_info { spg_info } does not match length of z_list { z_list } for molecule { mol_info ['name' ]} ."
182+ f"Length of spg_distribution_type { spg_distribution_type } does not match length of z_list { z_list } for molecule { mol_info ['name' ]} ."
180183 )
181184 mol = mol_info ["name" ] # System name
182185
@@ -222,7 +225,7 @@ def create_genarris_jobs(
222225 geometry_path = new_conf_path ,
223226 Z = z ,
224227 num_structures = num_structures_per_spg ,
225- spg_info = str (spg_info [i ]),
228+ spg_distribution_type = str (spg_distribution_type [i ]),
226229 )
227230
228231 # Create SLURM submission script if it doesn't exist
0 commit comments