How to use the forcebalance.output.getLogger function in forcebalance

To help you get started, we’ve selected a few forcebalance examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leeping / forcebalance / test / __main__.py View on Github external
for line in config:
            line = line.strip()
            if line:
                line = line.split('=')
                headless_options[line[0]]=line[1]

    os.chdir(os.path.dirname(__file__) + "/..")

    if not os.path.exists('/tmp/forcebalance'): os.mkdir('/tmp/forcebalance')
    warningHandler = forcebalance.output.CleanFileHandler('/tmp/forcebalance/test.err','w')
    warningHandler.setLevel(forcebalance.output.WARNING)
    logfile = "/tmp/forcebalance/%s.log" % time.strftime('%m%d%y_%H%M%S')
    debugHandler = forcebalance.output.CleanFileHandler(logfile,'w')
    debugHandler.setLevel(forcebalance.output.DEBUG)
    
    forcebalance.output.getLogger("forcebalance.test").addHandler(warningHandler)
    forcebalance.output.getLogger("forcebalance.test").addHandler(debugHandler)

    options['loglevel']=forcebalance.output.DEBUG
    
    runner=ForceBalanceTestRunner()
    results=runner.run(**options)

    if headless_options.has_key('enable_smtp')\
    and headless_options['enable_smtp'].lower() in ['true','error']:
        if headless_options['enable_smtp'].lower()=='true' or not results.wasSuccessful():
            import smtplib
            from email.mime.text import MIMEText
            from email.mime.multipart import MIMEMultipart

            # establish connection with smtp server
            server = smtplib.SMTP(host = headless_options["smtp_server"],
github leeping / forcebalance / test / __init__.py View on Github external
def __init__(self, logger=forcebalance.output.getLogger("forcebalance.test"), verbose = False):
        self.logger = logger
        forcebalance.output.getLogger("forcebalance.test")
github leeping / forcebalance / test / __init__.py View on Github external
def __init__(self):
        """Add logging capabilities to the standard TestResult implementation"""
        super(ForceBalanceTestResult,self).__init__()
        self.logger = forcebalance.output.getLogger('forcebalance.test.results')
github leeping / forcebalance / src / gmxqpio.py View on Github external
@date 12/2011
"""

import os
from re import match, sub
from forcebalance.nifty import isint, isfloat, _exec, warn_press_key, printcool_dictionary, LinkFile
import numpy as np
from forcebalance.molecule import Molecule
from copy import deepcopy
import itertools
from forcebalance.target import Target
from collections import OrderedDict
from forcebalance.finite_difference import *

from forcebalance.output import getLogger
logger = getLogger(__name__)

# Prerequisite: Water monomer geometry with:
# - Oxygen atom at the origin
# - Molecule in the xz-plane with C2 axis along z
# - Hydrogen molecules have positive z
def get_monomer_properties(print_stuff=0):
    # Multiply a quantity in nm to convert to a0
    nm_to_a0 = 1./0.05291772108
    # Multiply a quantity in e*a0 to convert to Debye
    ea0_to_debye = 0.393430307
    os.system("rm -rf *.log \#*")
    _exec(["./grompp"], print_command=False)
    _exec(["./mdrun"], outfnm="mdrun.txt", print_command=False)
    _exec("./trjconv -f traj.trr -o confout.gro -ndec 6".split(), stdin="0\n", print_command=False)
    x = []
    q = []
github leeping / forcebalance / src / abinitio.py View on Github external
import shutil
from forcebalance.nifty import col, eqcgmx, flat, floatornan, fqcgmx, invert_svd, kb, printcool, bohrang, warn_press_key
from numpy import append, array, cross, diag, dot, exp, log, mat, mean, ones, outer, sqrt, where, zeros, linalg, savetxt, hstack, sum, abs, vstack, max, arange
from forcebalance.target import Target
from forcebalance.molecule import Molecule, format_xyz_coord
from re import match, sub
import subprocess
from subprocess import PIPE
from forcebalance.finite_difference import fdwrap, f1d2p, f12d3p, in_fd
from collections import defaultdict, OrderedDict
import itertools
#from IPython import embed
#from _increment import AbInitio_Build

from forcebalance.output import getLogger
logger = getLogger(__name__)

class AbInitio(Target):

    """ Subclass of Target for fitting force fields to ab initio data.

    Currently Gromacs-X2, Gromacs, Tinker, OpenMM and AMBER are supported.

    We introduce the following concepts:
    - The number of snapshots
    - The reference energies and forces (eqm, fqm) and the file they belong in (qdata.txt)
    - The sampling simulation energies (emd0)
    - The WHAM Boltzmann weights (these are computed externally and passed in)
    - The QM Boltzmann weights (computed internally using the difference between eqm and emd0)

    There are also these little details:
    - Switches for whether to turn on certain Boltzmann weights (they stack)
github leeping / forcebalance / src / tinkerio.py View on Github external
from forcebalance import BaseReader
from subprocess import Popen, PIPE
from forcebalance.abinitio import AbInitio
from vibration import Vibration
from forcebalance.moments import Moments
from forcebalance.liquid import Liquid
from forcebalance.molecule import Molecule
from forcebalance.binding import BindingEnergy
from forcebalance.interaction import Interaction
from forcebalance.finite_difference import in_fd
from collections import OrderedDict
from forcebalance.optimizer import GoodStep
from forcebalance.unit import *

from forcebalance.output import getLogger
logger = getLogger(__name__)

pdict = {'VDW'          : {'Atom':[1], 2:'S',3:'T',4:'D'}, # Van der Waals distance, well depth, distance from bonded neighbor?
         'BOND'         : {'Atom':[1,2], 3:'K',4:'B'},     # Bond force constant and equilibrium distance (Angstrom)
         'ANGLE'        : {'Atom':[1,2,3], 4:'K',5:'B'},   # Angle force constant and equilibrium angle
         'UREYBRAD'     : {'Atom':[1,2,3], 4:'K',5:'B'},   # Urey-Bradley force constant and equilibrium distance (Angstrom)
         'MCHARGE'       : {'Atom':[1,2,3], 4:''},          # Atomic charge
         'DIPOLE'       : {0:'X',1:'Y',2:'Z'},             # Dipole moment in local frame
         'QUADX'        : {0:'X'},                         # Quadrupole moment, X component
         'QUADY'        : {0:'X',1:'Y'},                   # Quadrupole moment, Y component
         'QUADZ'        : {0:'X',1:'Y',2:'Z'},             # Quadrupole moment, Y component
         'POLARIZE'     : {'Atom':[1], 2:'A',3:'T'},       # Atomic dipole polarizability
         'BOND-CUBIC'   : {'Atom':[], 0:''},    # Below are global parameters.
         'BOND-QUARTIC' : {'Atom':[], 0:''},
         'ANGLE-CUBIC'  : {'Atom':[], 0:''},
         'ANGLE-QUARTIC': {'Atom':[], 0:''},
         'ANGLE-PENTIC' : {'Atom':[], 0:''},
github leeping / forcebalance / src / opt_geo_target.py View on Github external
@date 03/2019
"""
from __future__ import division
import os
import shutil
import numpy as np
import re
import subprocess
from copy import deepcopy
from collections import OrderedDict, defaultdict
from forcebalance.nifty import col, eqcgmx, flat, floatornan, fqcgmx, invert_svd, kb, printcool, printcool_dictionary, bohr2ang, warn_press_key
from forcebalance.target import Target
from forcebalance.molecule import Molecule
from forcebalance.finite_difference import fdwrap, f1d2p, f12d3p, in_fd
from forcebalance.output import getLogger
logger = getLogger(__name__)

RADIAN_2_DEGREE = 180 / np.pi

def periodic_diff(a, b, v_periodic):
    ''' convenient function for computing the minimum difference in periodic coordinates
    Parameters
    ----------
    a: np.ndarray or float
        Reference values in a numpy array
    b: np.ndarray or float
        Target values in a numpy arrary
    v_periodic: float > 0
        Value of the periodic boundary

    Returns
    -------
github leeping / forcebalance / src / gui / objects.py View on Github external
## The force field component of the project
            #forcefield  = FF(options)
            ## The objective function
            objective   = forcebalance.objective.Objective(self.opts, self.tgt_opts, self.properties['forcefield'].forcefield)
            ## The optimizer component of the project
            optimizer   = forcebalance.optimizer.Optimizer(self.opts, objective, self.properties['forcefield'].forcefield)
            ## Actually run the optimizer.
            optimizer.Run()
            
            
            resultopts = self.opts.copy()
            resultopts.update({"ffdir" : "result"})
            
            # temporarily silence nifty and forcefield while reading the results forcefield
            forcebalance.output.getLogger("forcebalance.forcefield").disabled = True
            forcebalance.output.getLogger("forcebalance.nifty").propagate = True
            self.properties['result'] = ForcefieldObject(resultopts)
            forcebalance.output.getLogger("forcebalance.forcefield").disabled = False
            forcebalance.output.getLogger("forcebalance.nifty").disabled = False
        except:
            import traceback
            logger = forcebalance.output.getLogger("forcebalance")
            logger.critical("Calculation failed\n%s" % traceback.format_exc())
github leeping / forcebalance / src / hydration.py View on Github external
from __future__ import division

from builtins import range
import os
import shutil
import numpy as np
from copy import deepcopy
from forcebalance.target import Target
from forcebalance.molecule import Molecule
from re import match, sub
from forcebalance.finite_difference import fdwrap, f1d2p, f12d3p, in_fd
from collections import defaultdict, OrderedDict
from forcebalance.nifty import getWorkQueue, queue_up, LinkFile, printcool, link_dir_contents, lp_dump, lp_load, _exec, kb, col, flat, uncommadash, statisticalInefficiency, isfloat

from forcebalance.output import getLogger
logger = getLogger(__name__)

class Hydration(Target):

    """ Subclass of Target for fitting force fields to hydration free energies."""
    
    def __init__(self,options,tgt_opts,forcefield):
        """Initialization."""
        
        # Initialize the SuperClass!
        super(Hydration,self).__init__(options,tgt_opts,forcefield)
        
        #======================================#
        # Options that are given by the parser #
        #======================================#
        self.set_option(tgt_opts,'hfedata_txt','datafile')
        self.set_option(tgt_opts,'hfemode')
github leeping / forcebalance / src / data / md_chain.py View on Github external
from builtins import str
from builtins import range
import os
import argparse
import numpy as np
import importlib as il

from forcebalance.nifty import lp_dump, lp_load, wopen
from forcebalance.nifty import printcool, printcool_dictionary
from forcebalance.molecule import Molecule

from collections import OrderedDict

from forcebalance.output import getLogger
logger = getLogger(__name__)

#========================================================#
#| Global, user-tunable variables (simulation settings) |#
#========================================================#

parser = argparse.ArgumentParser()
parser.add_argument('quantities', nargs='+',
                    help='Quantities to calculate')
parser.add_argument('--engine', default='gromacs',
                    help='MD program that we are using; choose "gromacs"')
parser.add_argument('--length', type=int, default=1,
                    help='Length of simulation chain')
parser.add_argument('--name', default='sim',
                    help='Default simulation names')
parser.add_argument('--temperature', type=float, default=None,
                    help='Simulation temperature')