Skip to content

Commit

Permalink
combine_pair separate logfiles for diff pairs
Browse files Browse the repository at this point in the history
Instead of one giant "flas" file
  • Loading branch information
MatthewRHermes committed Jul 22, 2024
1 parent c3f9baf commit 43278d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions my_pyscf/mcscf/lasscf_async/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,28 @@ def __exit__(self, type, value, traceback):
self.las.with_df.stdout = self.las_stdout

def relax (las, kf, freeze_inactive=False, unfrozen_frags=None):
if unfrozen_frags is None: frozen_frags = []
flas_stdout = getattr (las, '_flas_stdout', None)
if unfrozen_frags is None:
frozen_frags = []
flas_tail = '.flas'
else:
unfrozen_frags = tuple (sorted (unfrozen_frags)) # sorted
frozen_frags = [i for i in range (las.nfrags) if i not in unfrozen_frags]
flas_stdout = flas_stdout.get (unfrozen_frags, None)
flas_tail = '.' + '.'.join ([str (s) for s in unfrozen_frags])
log = lib.logger.new_logger (las, las.verbose)
flas_stdout = getattr (las, '_flas_stdout', None)
if flas_stdout is None:
output = getattr (las.mol, 'output', None)
if not ((output is None) or (output=='/dev/null')):
flas_output = output + '.flas'
flas_output = output + flas_tail
if las.verbose > lib.logger.QUIET:
if os.path.isfile (flas_output):
print('overwrite output file: %s' % flas_output)
else:
print('output file: %s' % flas_output)
flas_stdout = open (flas_output, 'w')
las._flas_stdout = flas_stdout
if unfrozen_frags is None: las._flas_stdout = flas_stdout
else: las._flas_stdout[unfrozen_frags] = flas_stdout
else:
flas_stdout = las.stdout
with flas_stdout_env (las, flas_stdout):
Expand Down
4 changes: 2 additions & 2 deletions my_pyscf/mcscf/lasscf_async/lasscf_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def kernel (las, mo_coeff=None, ci0=None, conv_tol_grad=1e-4,
log = lib.logger.new_logger(las, verbose)
t0 = (lib.logger.process_clock(), lib.logger.perf_counter())
kf0 = las.get_keyframe (mo_coeff, ci0)
las._flas_stdout = None # TODO: more elegant model for this
las._flas_stdout = {} # TODO: more elegant model for this

###############################################################################################
################################## Begin actual kernel logic ##################################
Expand Down Expand Up @@ -90,7 +90,7 @@ def kernel (las, mo_coeff=None, ci0=None, conv_tol_grad=1e-4,
################################### End actual kernel logic ###################################
###############################################################################################

if getattr (las, '_flas_stdout', None) is not None: las._flas_stdout.close ()
for key, val in las._flas_stdout.items (): val.close ()
# TODO: more elegant model for this
mo_coeff, ci1, h2eff_sub, veff = kf1.mo_coeff, kf1.ci, kf1.h2eff_sub, kf1.veff
t1 = log.timer ('LASSCF {} macrocycles'.format (it), *t0)
Expand Down

0 comments on commit 43278d3

Please sign in to comment.