Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions nexus/nexus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
from pathlib import Path

from .nexus_version import nexus_version
from .generic import generic_settings
from .developer import obj, log, NexusError
from .developer import obj, nxs_print, NexusError
from .debug import ci
from .utilities import path_string

Expand Down Expand Up @@ -218,7 +217,7 @@ def __call__(self,**kwargs):
write_splash()

# print version information
self.log("Checking current machine for Nexus dependencies...\n")
self.nxs_print("Checking current machine for Nexus dependencies...\n")
pkg_sort = {
"numpy": 0,
"scipy": 1,
Expand Down Expand Up @@ -293,9 +292,9 @@ def __call__(self,**kwargs):

version_text += "\n"

self.log(version_text)
self.nxs_print(version_text)

self.log('Applying user settings')
self.nxs_print('Applying user settings')

# assign simple variables
for name in Settings.core_assign_vars:
Expand Down Expand Up @@ -505,9 +504,9 @@ def process_machine_settings(self,mset):
if 'machine' in mset:
machine_name = mset.machine
if machine_name in {"ws", "workstation"}:
self.log("Automatically detecting physical CPU cores for workstation...", n=1)
self.nxs_print("Automatically detecting physical CPU cores for workstation...", n=1)
n_cores = get_cpu_cores()
self.log(f"Using {n_cores} core workstation", n=1)
self.nxs_print(f"Using {n_cores} core workstation", n=1)
machine_name = f"ws{n_cores}"

if not Machine.exists(machine_name):
Expand Down
10 changes: 5 additions & 5 deletions nexus/nexus/basisset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from types import MappingProxyType
import numpy as np
from .periodic_table import Elements
from .developer import DevBase, obj, log, NexusError
from .developer import DevBase, obj, nxs_print, NexusError
from .fileio import TextFile
from .utilities import path_string, to_str

Expand Down Expand Up @@ -64,11 +64,11 @@ def readbs(self,*bsfiles):
bsfiles = bsfiles[0]
#end if
bss = []
log('')
log(' Basissets')
nxs_print('')
nxs_print(' Basissets')
for filepath in bsfiles:
filepath_str = str(filepath)
log(' reading basis: '+filepath_str)
nxs_print(' reading basis: '+filepath_str)
ext = filepath_str.split('.')[-1].lower()
if ext=='gms_bas' or ext=='bas':
bs = gamessBasisFile(filepath_str)
Expand All @@ -77,7 +77,7 @@ def readbs(self,*bsfiles):
#end if
bss.append(bs)
#end for
log('')
nxs_print('')
self.addbs(bss)
#end def readbs

Expand Down
10 changes: 5 additions & 5 deletions nexus/nexus/bin/qdens
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class QDBase(DevBase):

def vlog(self,*args,**kwargs):
if self.verbose:
DevBase.log(self,*args,**kwargs)
DevBase.nxs_print(self,*args,**kwargs)
#end if
#end def vlog

Expand All @@ -210,7 +210,7 @@ class QDBase(DevBase):
#end def vmlog

def help(self):
self.log('\n'+self.parser.format_help().strip()+'\n')
self.nxs_print('\n'+self.parser.format_help().strip()+'\n')
#end def help

# options accessor functions
Expand Down Expand Up @@ -1213,8 +1213,8 @@ class QMCDensityProcessor(QDBase):
self.vlog(f'\n{self.name} initializing')

if self.verbose:
self.log('\noptions provided:')
self.log(str(self.options))
self.nxs_print('\noptions provided:')
self.nxs_print(str(self.options))
#end if


Expand Down Expand Up @@ -1496,7 +1496,7 @@ class QMCDensityProcessor(QDBase):
#end if

if opt.verbose and opt.input_metadata is not None:
self.log(f'input density metadata found for series: {sorted(opt.input_metadata.series.keys())}')
self.nxs_print(f'input density metadata found for series: {sorted(opt.input_metadata.series.keys())}')
#end if

for file in files_in:
Expand Down
24 changes: 12 additions & 12 deletions nexus/nexus/bin/qdens-radial
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class QDRBase(DevBase):

def vlog(self,*args,**kwargs):
if self.verbose:
DevBase.log(self,*args,**kwargs)
DevBase.nxs_print(self,*args,**kwargs)
#end if
#end def vlog

Expand All @@ -107,7 +107,7 @@ class QDRBase(DevBase):
#end def vmlog

def help(self):
self.log('\n'+self.parser.format_help().strip()+'\n')
self.nxs_print('\n'+self.parser.format_help().strip()+'\n')
#end def help

#end class QDBase
Expand Down Expand Up @@ -305,7 +305,7 @@ class QMCDensityRadialProcessor(QDRBase):
# if VMC file is given, perform extrapolation before
# instantiating ChargeDensity object
if opt.vmc_file is not None:
self.log('Extrapolating from VMC and DMC densities...')
self.nxs_print('Extrapolating from VMC and DMC densities...')
vmc_xsf_data = XsfFile(filepath=opt.vmc_file)
dmc_xsf_data = XsfFile(filepath=file)
# Initialize extrapolated XsfFile object
Expand All @@ -319,14 +319,14 @@ class QMCDensityRadialProcessor(QDRBase):
dmc_xsf_data = XsfFile(filepath=file)
file = deepcopy(dmc_xsf_data)
if opt.write_extrap:
self.log('\nWARNING: You provided --write, however, extrapolated density will not be written since a VMC file was not provided (via --vmc=VMC_FILE).\n')
self.nxs_print('\nWARNING: You provided --write, however, extrapolated density will not be written since a VMC file was not provided (via --vmc=VMC_FILE).\n')
#end if
#end if

show_error=False
# If error files are given, then user wants resampled error bars
if opt.dmc_err_file is not None:
self.log('Resampling to obtain error bar (NOTE: This can be slow)...')
self.nxs_print('Resampling to obtain error bar (NOTE: This can be slow)...')
if opt.vmc_file is not None and opt.vmc_err_file is not None:
# Data without errors
vmc_xsf_data = XsfFile(filepath=opt.vmc_file)
Expand Down Expand Up @@ -381,9 +381,9 @@ class QMCDensityRadialProcessor(QDRBase):
#end if

nsamples = opt.nsamples
self.log(f'Will compute {nsamples} samples...')
self.nxs_print(f'Will compute {nsamples} samples...')
for i in range(nsamples):
self.log(f'sample: {i}')
self.nxs_print(f'sample: {i}')
resample_xsf_data = deepcopy(file)
for d1_idx, d1 in enumerate(file.data[3]['density']['density'].values):
for d2_idx, d2 in enumerate(d1):
Expand Down Expand Up @@ -500,7 +500,7 @@ class QMCDensityRadialProcessor(QDRBase):
cd.set_attribute('density_units','A') # xsf format uses Angstrom units which makes the QMCPACK density units (e/Angstrom^3) after volume normalization
#end if

self.log('\nNorm:',cd.norm())
self.nxs_print('\nNorm:',cd.norm())

if opt.plot:
if opt.species is None:
Expand Down Expand Up @@ -534,9 +534,9 @@ class QMCDensityRadialProcessor(QDRBase):
r = opt.radii[0]
#end if
if not show_error:
self.log(f'{cstr} Value of {at} Species at Cutoff {r} is: {rdens.tot[at].density[-1]:.8f}\n')
self.nxs_print(f'{cstr} Value of {at} Species at Cutoff {r} is: {rdens.tot[at].density[-1]:.8f}\n')
else:
self.log(f'{cstr} Value of {at} Species at Cutoff {r} is: {rdens.tot[at].density[-1]:.8f} +/- {std_dict[at]:.8f}\n')
self.nxs_print(f'{cstr} Value of {at} Species at Cutoff {r} is: {rdens.tot[at].density[-1]:.8f} +/- {std_dict[at]:.8f}\n')
#end if
#end for
else:
Expand All @@ -549,9 +549,9 @@ class QMCDensityRadialProcessor(QDRBase):
r = opt.radii[0]
#end if
if not show_error:
self.log(f'{cstr} Value of {at} Species at Cutoff {r} is: {rdens.tot[at].density[-1]:.8f}\n')
self.nxs_print(f'{cstr} Value of {at} Species at Cutoff {r} is: {rdens.tot[at].density[-1]:.8f}\n')
else:
self.log(f'{cstr} Value of {at} Species at Cutoff {r} is: {rdens.tot[at].density[-1]:.8f} +/- {std_dict[at]:.8f}\n')
self.nxs_print(f'{cstr} Value of {at} Species at Cutoff {r} is: {rdens.tot[at].density[-1]:.8f} +/- {std_dict[at]:.8f}\n')
#end if
#end for
#end if
Expand Down
26 changes: 13 additions & 13 deletions nexus/nexus/bin/qmc-fit
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def find_nexus_modules():

# Load Nexus modules
find_nexus_modules()
from nexus.developer import obj,log
from nexus.developer import obj,nxs_print
from nexus.numerics import jackknife,jackknife_aux
from nexus.numerics import simstats,equilibration_length
from nexus.numerics import curve_fit,least_squares
Expand Down Expand Up @@ -424,7 +424,7 @@ def timestep_fit(args):
scalar_files = sorted(opt.scalar_files)

if len(scalar_files)==0:
log('\n'+parser.format_help().strip()+'\n')
nxs_print('\n'+parser.format_help().strip()+'\n')
sys.exit()
#end if

Expand Down Expand Up @@ -472,11 +472,11 @@ def timestep_fit(args):
pvals.append('({0} +/- {1})'.format(*stat_strings(pmean[n],perror[n])))
#end for

log('\nfit function : '+opt.fit_function)
log('fitted formula: '+func_info.format.format(*pvals))
nxs_print('\nfit function : '+opt.fit_function)
nxs_print('fitted formula: '+func_info.format.format(*pvals))
for pname,pfunc in func_info.params: # noqa: B007
pm,pe = stat_strings(*auxres[pname])
log(f'{pname:<14}: {pm} +/- {pe} Ha\n')
nxs_print(f'{pname:<14}: {pm} +/- {pe} Ha\n')
#end for

# plot the fit (if available)
Expand Down Expand Up @@ -546,7 +546,7 @@ def hubbard_u_fit(args):
#end if
x = opt.exx
else:
log("\n Please provide either EXX or Hubbard_U values")
nxs_print("\n Please provide either EXX or Hubbard_U values")
#end if

parse_list(opt,'equils',int,len1=True)
Expand All @@ -562,8 +562,8 @@ def hubbard_u_fit(args):
pvals.append('({0} +/- {1})'.format(*stat_strings(pmean[n],perror[n])))
#end for

log('\nfit function : '+opt.fit_function)
log('fitted formula: '+func_info.format.format(*pvals))
nxs_print('\nfit function : '+opt.fit_function)
nxs_print('fitted formula: '+func_info.format.format(*pvals))
for pname,pfunc in func_info.params: # noqa: B007
for i in range(len(auxres[pname][0])):
pm,pe = stat_strings(*np.array(auxres[pname])[:,i])
Expand All @@ -581,7 +581,7 @@ def hubbard_u_fit(args):
else:
param = pname
#end if
log(f'root {i+1} {param:<14}: {pm} +/- {pe} {unit}')
nxs_print(f'root {i+1} {param:<14}: {pm} +/- {pe} {unit}')
#end for
# plot the fit (if available)

Expand Down Expand Up @@ -657,13 +657,13 @@ def eos_fit(args):
for n in range(len(pmean)):
pvals.append('({0} +/- {1})'.format(*stat_strings(pmean[n],perror[n])))
#end for
log('\nfit function : '+opt.fit_function)
log('fitted formula: '+func_info.format.format(*pvals))
nxs_print('\nfit function : '+opt.fit_function)
nxs_print('fitted formula: '+func_info.format.format(*pvals))

if 'params' in func_info.keys():
for pname,pfunc in func_info.params: # noqa: B007
pm,pe = stat_strings(*np.array(auxres[pname]))
log(f'{pname}: {pm} +/- {pe} ')
nxs_print(f'{pname}: {pm} +/- {pe} ')
#end for

# plot the fit (if available)
Expand Down Expand Up @@ -751,7 +751,7 @@ if __name__=='__main__':
fit_types = sorted(all_fit_functions.keys())
parser, args = parse_args()
if len(args.scalar_files) == 0:
log('\n'+'Please provide scalar files'+'\n')
nxs_print('\n'+'Please provide scalar files'+'\n')
parser.print_help()
sys.exit()
#end if
Expand Down
2 changes: 1 addition & 1 deletion nexus/nexus/bin/qmca
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class QBase(DevBase):
text+=str(t)+' '
#end for
pad = n*' '
self._logfile.write(pad+text.replace('\n','\n'+pad)+'\n')
sys.stdout.write(pad+text.replace('\n','\n'+pad)+'\n')
#end def log


Expand Down
13 changes: 3 additions & 10 deletions nexus/nexus/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@


from .generic import NexusError, FileFormatError, NotAnElementError # noqa: F401
from .generic import error, log, warn, message # noqa: F401
from .generic import error, nxs_print, warn, message # noqa: F401


import traceback
from .generic import generic_settings


def deprecation_error():
Expand All @@ -58,15 +57,9 @@ def __iter__(self): deprecation_error()
# change from deepcopy to shallow copy, blow up
def copy(self): deprecation_error()

# logging - unique to Nexus-style DevBase (future refactor)
@property
def _logfile(self):
return generic_settings.devlog


def log(self,*a,**kw):
kw.setdefault('logfile',self._logfile)
log(*a,**kw)
def nxs_print(self,*a,**kw):
nxs_print(*a,**kw)

def warn(self,msg,indent=' '):
warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
settings(
pseudo_dir = '../pseudopotentials',
results = '',
sleep = 3,
machine = 'ws16',
sleep = 0.5,
machine = 'ws8',
)

system = generate_physical_system(
Expand All @@ -26,7 +26,7 @@
scf = generate_pwscf(
identifier = 'scf',
path = 'diamond/scf',
job = job(cores=16,app='pw.x'),
job = job(cores=6,app='pw.x'),
input_type = 'generic',
calculation = 'scf',
input_dft = 'lda',
Expand Down
Loading
Loading