Exemplo n.º 1
0
    def __init__(self, root, **kwargs):
        tk.LabelFrame.__init__(self, root, text="Console", **kwargs)
        
        self.console = tk.Text(self,
                            state=tk.DISABLED,
                            cursor="arrow",
                            fg="#FFFFFF",
                            bg="#000000")
        self.console.pack(fill=tk.BOTH, expand=1)
        
        # console colors corresponding to ANSI escape sequences
        self.console.tag_config("0", foreground="white", background="black")
        #self.console.tag_config("1")  # make text bold
        self.console.tag_config("44", background="blue")
        self.console.tag_config("91", foreground="red")
        self.console.tag_config("92", foreground="green")
        self.console.tag_config("93", foreground="yellow")
        self.console.tag_config("94", foreground="blue")
        self.console.tag_config("95", foreground="purple")

        getLogger("forcebalance").addHandler(ConsolePaneHandler(self))
        getLogger("forcebalance").setLevel(INFO)
        
        # scroll to bottom of text when widget is resized
        self.bind("<Configure>", lambda e: self.console.yview(tk.END))
Exemplo n.º 2
0
    def meta_indicate(self, customdir=None):
        """ 

        Wrap around the indicate function, so it can print to screen and
        also to a file.  If reading from checkpoint file, don't call
        the indicate() function, instead just print the file contents
        to the screen.
        
        """
        # Using the module level logger
        logger = getLogger(__name__)
        # Note that reading information is not supported for custom folders (e.g. microiterations during search)
        if self.rd is not None and (
                not self.evaluated
        ) and self.read_indicate and customdir is None:
            # Move into the directory for reading data,
            cwd = os.getcwd()
            os.chdir(self.absrd())
            logger.info(open('indicate.log').read())
            os.chdir(cwd)
        else:
            if self.write_indicate:
                # Go into the directory where the job is running
                cwd = os.getcwd()
                os.chdir(os.path.join(self.root, self.rundir))
                # If indicate.log already exists then we've made some kind of mistake.
                if os.path.exists('indicate.log'):
                    logger.error(
                        'indicate.log should not exist yet in this directory: %s\n'
                        % os.getcwd())
                    raise RuntimeError
                # Add a handler for printing to screen and file
                logger = getLogger("forcebalance")
                hdlr = forcebalance.output.RawFileHandler('indicate.log')
                logger.addHandler(hdlr)
            # Execute the indicate function
            self.indicate()
            if self.write_indicate:
                # Remove the handler (return to normal printout)
                logger.removeHandler(hdlr)
                # Return to the module level logger
                logger = getLogger(__name__)
                # The module level logger now prints the indicator
                logger.info(open('indicate.log').read())
                # Go back to the directory where we were
                os.chdir(cwd)
Exemplo n.º 3
0
    def meta_indicate(self, customdir=None):

        """ 

        Wrap around the indicate function, so it can print to screen and
        also to a file.  If reading from checkpoint file, don't call
        the indicate() function, instead just print the file contents
        to the screen.
        
        """
        # Using the module level logger
        logger = getLogger(__name__)
        # Note that reading information is not supported for custom folders (e.g. microiterations during search)
        if self.rd is not None and (not self.evaluated) and self.read_indicate and customdir is None:
            # Move into the directory for reading data, 
            cwd = os.getcwd()
            os.chdir(self.absrd())
            logger.info(open('indicate.log').read())
            os.chdir(cwd)
        else:
            if self.write_indicate:
                # Go into the directory where the job is running
                cwd = os.getcwd()
                os.chdir(os.path.join(self.root, self.rundir))
                # If indicate.log already exists then we've made some kind of mistake.
                if os.path.exists('indicate.log'):
                    logger.error('indicate.log should not exist yet in this directory: %s\n' % os.getcwd())
                    raise RuntimeError
                # Add a handler for printing to screen and file
                logger = getLogger("forcebalance")
                hdlr = forcebalance.output.RawFileHandler('indicate.log')
                logger.addHandler(hdlr)
            # Execute the indicate function
            self.indicate()
            if self.write_indicate:
                # Remove the handler (return to normal printout)
                logger.removeHandler(hdlr)
                # Return to the module level logger
                logger = getLogger(__name__)
                # The module level logger now prints the indicator
                logger.info(open('indicate.log').read())
                # Go back to the directory where we were
                os.chdir(cwd)
Exemplo n.º 4
0
import numpy as np
from forcebalance.molecule import Molecule
from re import match, sub
import subprocess
from subprocess import PIPE
try:
    from lxml import etree
except: pass
from pymbar import pymbar
import itertools
from collections import defaultdict, namedtuple
from forcebalance.optimizer import Counter, GoodStep
import csv

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

def weight_info(W, PT, N_k, verbose=True):
    C = []
    N = 0
    W += 1.0e-300
    I = np.exp(-1*np.sum((W*np.log(W))))
    for ns in N_k:
        C.append(sum(W[N:N+ns]))
        N += ns
    C = np.array(C)
    if verbose:
        logger.info("MBAR Results for Phase Point %s, Box, Contributions:\n" % str(PT))
        logger.info(str(C) + '\n')
        logger.info("InfoContent: % .2f snapshots (%.2f %%)\n" % (I, 100*I/len(W)))
    return C
Exemplo n.º 5
0
from builtins import range
import abc
import os
import subprocess
import shutil
import numpy as np
import time
from collections import OrderedDict
import tarfile
import forcebalance
from forcebalance.nifty import row, col, printcool_dictionary, link_dir_contents, createWorkQueue, getWorkQueue, wq_wait1, getWQIds, wopen, warn_press_key, _exec, lp_load, LinkFile
from forcebalance.finite_difference import fdwrap_G, fdwrap_H, f1d2p, f12d3p, in_fd
from forcebalance.optimizer import Counter
from forcebalance.output import getLogger
from future.utils import with_metaclass
logger = getLogger(__name__)


class Target(with_metaclass(abc.ABCMeta, forcebalance.BaseClass)):
    """
    Base class for all fitting targets.
    
    In ForceBalance a Target is defined as a set of reference data
    plus a corresponding method to simulate that data using the force field.
    
    The 'computable quantities' may include energies and forces where the
    reference values come from QM calculations (energy and force matching),
    energies from an EDA analysis (Maybe in the future, FDA?), molecular
    properties (like polarizability, refractive indices, multipole moments
    or vibrational frequencies), relative entropies, and bulk properties.
    Single-molecule or bulk properties can even come from the experiment!