ForceBalance API  1.3
Automated optimization of force fields and empirical potentials
Classes | Namespaces | Functions | Variables
nifty.py File Reference

Go to the source code of this file.

Classes

class  src.nifty.RawStreamHandler
 Exactly like StreamHandler, except no newline character is printed at the end of each message. More...
 
class  src.nifty.RawFileHandler
 Exactly like FileHandler, except no newline character is printed at the end of each message. More...
 
class  src.nifty.LineChunker
 

Namespaces

 src.nifty
 
 forcebalance.nifty
 Nifty functions, intended to be imported by any module within ForceBalance.
 

Functions

def src.nifty.pvec1d (vec1d, precision=1, format="e", loglevel=INFO)
 Printout of a 1-D vector. More...
 
def src.nifty.astr (vec1d, precision=4)
 Write an array to a string so we can use it to key a dictionary. More...
 
def src.nifty.pmat2d (mat2d, precision=1, format="e", loglevel=INFO)
 Printout of a 2-D array. More...
 
def src.nifty.grouper (iterable, n)
 Collect data into fixed-length chunks or blocks. More...
 
def src.nifty.encode (l)
 
def src.nifty.segments (e)
 
def src.nifty.commadash (l)
 
def src.nifty.uncommadash (s)
 
def src.nifty.natural_sort (l)
 Return a natural sorted list. More...
 
def src.nifty.printcool (text, sym="#", bold=False, color=2, ansi=None, bottom='-', minwidth=50, center=True, sym2="=")
 Cool-looking printout for slick formatting of output. More...
 
def src.nifty.printcool_dictionary (Dict, title="Dictionary Keys : Values", bold=False, color=2, keywidth=25, topwidth=50, center=True, leftpad=0)
 See documentation for printcool; this is a nice way to print out keys/values in a dictionary. More...
 
def src.nifty.isint (word)
 ONLY matches integers! If you have a decimal point? None shall pass! More...
 
def src.nifty.isfloat (word)
 Matches ANY number; it can be a decimal, scientific notation, what have you CAUTION - this will also match an integer. More...
 
def src.nifty.isdecimal (word)
 Matches things with a decimal only; see isint and isfloat. More...
 
def src.nifty.floatornan (word)
 Returns a big number if we encounter NaN. More...
 
def src.nifty.col (vec)
 Given any list, array, or matrix, return a 1-column 2D array. More...
 
def src.nifty.row (vec)
 Given any list, array, or matrix, return a 1-row 2D array. More...
 
def src.nifty.flat (vec)
 Given any list, array, or matrix, return a single-index array. More...
 
def src.nifty.est124 (val)
 Given any positive floating point value, return a value [124]e+xx that is closest to it in the log space. More...
 
def src.nifty.est1234568 (val)
 Given any positive floating point value, return a value [1234568]e+xx that is closest to it in the log space. More...
 
def src.nifty.monotonic (arr, start, end)
 
def src.nifty.monotonic_decreasing (arr, start=None, end=None, verbose=False)
 Return the indices of an array corresponding to strictly monotonic decreasing behavior. More...
 
def src.nifty.orthogonalize (vec1, vec2)
 Given two vectors vec1 and vec2, project out the component of vec1 that is along the vec2-direction. More...
 
def src.nifty.invert_svd (X, thresh=1e-12)
 Invert a matrix using singular value decomposition. More...
 
def src.nifty.get_least_squares (x, y, w=None, thresh=1e-12)
 
def src.nifty.statisticalInefficiency (A_n, B_n=None, fast=False, mintime=3, warn=True)
 Compute the (cross) statistical inefficiency of (two) timeseries. More...
 
def src.nifty.mean_stderr (ts)
 Return mean and standard deviation of a time series ts. More...
 
def src.nifty.multiD_statisticalInefficiency (A_n, B_n=None, fast=False, mintime=3, warn=True)
 
def src.nifty.lp_dump (obj, fnm, protocol=0)
 Write an object to a zipped pickle file specified by the path. More...
 
def src.nifty.lp_load (fnm)
 Read an object from a bzipped file specified by the path. More...
 
def src.nifty.getWorkQueue ()
 
def src.nifty.getWQIds ()
 
def src.nifty.createWorkQueue (wq_port, debug=True, name=package)
 
def src.nifty.destroyWorkQueue ()
 
def src.nifty.queue_up (wq, command, input_files, output_files, tag=None, tgt=None, verbose=True, print_time=60)
 Submit a job to the Work Queue. More...
 
def src.nifty.queue_up_src_dest (wq, command, input_files, output_files, tag=None, tgt=None, verbose=True, print_time=60)
 Submit a job to the Work Queue. More...
 
def src.nifty.wq_wait1 (wq, wait_time=10, wait_intvl=1, print_time=60, verbose=False)
 This function waits ten seconds to see if a task in the Work Queue has finished. More...
 
def src.nifty.wq_wait (wq, wait_time=10, wait_intvl=10, print_time=60, verbose=False)
 This function waits until the work queue is completely empty. More...
 
def src.nifty.click ()
 Stopwatch function for timing. More...
 
def src.nifty.splitall (path)
 
def src.nifty.bak (path, dest=None, cwd=None, start=1)
 
def src.nifty.onefile (fnm=None, ext=None, err=False)
 
def src.nifty.listfiles (fnms=None, ext=None, err=False, dnm=None)
 
def src.nifty.extract_tar (tarfnm, fnms, force=False)
 Extract a list of files from .tar archive with any compression. More...
 
def src.nifty.GoInto (Dir)
 
def src.nifty.allsplit (Dir)
 
def src.nifty.Leave (Dir)
 
def src.nifty.MissingFileInspection (fnm)
 
def src.nifty.wopen (dest, binary=False)
 If trying to write to a symbolic link, remove it first. More...
 
def src.nifty.LinkFile (src, dest, nosrcok=False)
 
def src.nifty.CopyFile (src, dest)
 
def src.nifty.link_dir_contents (abssrcdir, absdestdir)
 
def src.nifty.remove_if_exists (fnm)
 Remove the file if it exists (doesn't return an error). More...
 
def src.nifty.which (fnm)
 
def src.nifty.copy_tree_over (src, dest)
 Copy a source directory tree to a destination directory tree, overwriting files as necessary. More...
 
def src.nifty.warn_press_key (warning, timeout=10)
 
def src.nifty.warn_once (warning, warnhash=None)
 Prints a warning but will only do so once in a given run. More...
 
def src.nifty.concurrent_map (func, data)
 Similar to the bultin function map(). More...
 

Variables

string src.nifty.package = "ForceBalance"
 
 src.nifty.logger = getLogger(__name__)
 
 src.nifty.handler = RawStreamHandler()
 
bool src.nifty.HaveBZ2 = True
 
bool src.nifty.HaveGZ = True
 
 src.nifty.rootdir = os.path.dirname(os.path.abspath(__file__))
 
float src.nifty.kb = 0.008314462618
 Boltzmann constant in kJ mol^-1 k^-1. More...
 
float src.nifty.kb_si = 1.380649e-23
 
float src.nifty.bohr2ang = 0.529177210903
 
float src.nifty.ang2bohr = 1.0 / bohr2ang
 
float src.nifty.au2kcal = 627.5094740630558
 
float src.nifty.kcal2au = 1.0 / au2kcal
 
float src.nifty.au2kj = 2625.4996394798254
 
float src.nifty.kj2au = 1.0 / au2kj
 
float src.nifty.grad_au2gmx = 49614.75258920567
 
float src.nifty.grad_gmx2au = 1.0 / grad_au2gmx
 
float src.nifty.au2evang = 51.422067476325886
 
float src.nifty.evang2au = 1.0 / au2evang
 
int src.nifty.c_lightspeed = 299792458.
 
float src.nifty.hbar = 1.054571817e-34
 
float src.nifty.avogadro = 6.02214076e23
 
float src.nifty.au_mass = 9.1093837015e-31
 
float src.nifty.amu_mass = 1.66053906660e-27
 
float src.nifty.amu2au = amu_mass / au_mass
 
int src.nifty.cm2au = 100 * c_lightspeed * (2*np.pi*hbar) * avogadro / 1000 / au2kj
 
float src.nifty.ambervel2au = 9.349961132249932e-04
 
float src.nifty.eqcgmx = au2kj
 Q-Chem to GMX unit conversion for energy. More...
 
float src.nifty.fqcgmx = -grad_au2gmx
 Q-Chem to GMX unit conversion for force. More...
 
 src.nifty.WORK_QUEUE = None
 
 src.nifty.WQIDS = defaultdict(list)
 
list src.nifty.specific_lst
 
 src.nifty.specific_dct = dict(list(itertools.chain(*[[(j,i[1]) for j in i[0]] for i in specific_lst])))