Exemple #1
0
from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint
from fullrmc.Core.GroupSelector import RecursiveGroupSelector
from fullrmc.Selectors.RandomSelectors import RandomSelector
from fullrmc.Core.MoveGenerator import MoveGeneratorCollector
from fullrmc.Generators.Translations import TranslationGenerator
from fullrmc.Generators.Rotations import RotationGenerator

##########################################################################################
#####################################  CREATE ENGINE  ####################################
# file names
expDataPath = "Xrays.gr"
pdbPath = "CO2.pdb"
enginePath = "CO2.rmc"
FRESH_START = False

ENGINE = Engine(path=None)
if not ENGINE.is_engine(enginePath) or FRESH_START:
    # initialize engine
    ENGINE = Engine(path=enginePath, freshStart=True)
    ENGINE.set_pdb(pdbPath)
    PDF_CONSTRAINT = PairDistributionConstraint(experimentalData=expDataPath,
                                                weighting="atomicNumber")
    IMD_CONSTRAINT = InterMolecularDistanceConstraint(defaultDistance=1.4)
    B_CONSTRAINT = BondConstraint()
    BA_CONSTRAINT = BondsAngleConstraint()
    # add constraints
    ENGINE.add_constraints(
        [PDF_CONSTRAINT, IMD_CONSTRAINT, B_CONSTRAINT, BA_CONSTRAINT])
    B_CONSTRAINT.create_bonds_by_definition(bondsDefinition={
        "CO2": [('C', 'O1', 0.52, 1.4), ('C', 'O2', 0.52, 1.4)]
    })
Exemple #2
0
def create_engine():
    # create engine
    ENGINE = Engine(path=None)
    ENGINE.set_pdb(pdbPath)
    # initialize constraints
    B_CONSTRAINT   = BondConstraint()
    BA_CONSTRAINT  = BondsAngleConstraint()
    IA_CONSTRAINT  = ImproperAngleConstraint()
    # add constraints
    ENGINE.add_constraints([B_CONSTRAINT])
    B_CONSTRAINT.create_bonds_by_definition( bondsDefinition={"THF": [('O' ,'C1' , 1.20, 1.70),
                                                                      ('O' ,'C4' , 1.20, 1.70),
                                                                      ('C1','C2' , 1.25, 1.90),
                                                                      ('C2','C3' , 1.25, 1.90),
                                                                      ('C3','C4' , 1.25, 1.90),
                                                                      ('C1','H11', 0.88, 1.16),('C1','H12', 0.88, 1.16),
                                                                      ('C2','H21', 0.88, 1.16),('C2','H22', 0.88, 1.16),
                                                                      ('C3','H31', 0.88, 1.16),('C3','H32', 0.88, 1.16),
                                                                      ('C4','H41', 0.88, 1.16),('C4','H42', 0.88, 1.16)] })
    ENGINE.add_constraints([BA_CONSTRAINT])
    BA_CONSTRAINT.create_angles_by_definition( anglesDefinition={"THF": [ ('O'  ,'C1' ,'C4' , 105, 125),
                                                                          ('C1' ,'O'  ,'C2' , 100, 120),
                                                                          ('C4' ,'O'  ,'C3' , 100, 120),
                                                                          ('C2' ,'C1' ,'C3' , 95 , 115),
                                                                          ('C3' ,'C2' ,'C4' , 95 , 115),
                                                                          # H-C-H angle
                                                                          ('C1' ,'H11','H12', 98 , 118),
                                                                          ('C2' ,'H21','H22', 98 , 118),
                                                                          ('C3' ,'H31','H32', 98 , 118),
                                                                          ('C4' ,'H41','H42', 98 , 118),
                                                                          # H-C-O angle
                                                                          ('C1' ,'H11','O'  , 100, 120),
                                                                          ('C1' ,'H12','O'  , 100, 120),
                                                                          ('C4' ,'H41','O'  , 100, 120),
                                                                          ('C4' ,'H42','O'  , 100, 120),                                                                           
                                                                          # H-C-C
                                                                          ('C1' ,'H11','C2' , 103, 123),
                                                                          ('C1' ,'H12','C2' , 103, 123),
                                                                          ('C2' ,'H21','C1' , 103, 123),
                                                                          ('C2' ,'H21','C3' , 103, 123),
                                                                          ('C2' ,'H22','C1' , 103, 123),
                                                                          ('C2' ,'H22','C3' , 103, 123),
                                                                          ('C3' ,'H31','C2' , 103, 123),
                                                                          ('C3' ,'H31','C4' , 103, 123),
                                                                          ('C3' ,'H32','C2' , 103, 123),
                                                                          ('C3' ,'H32','C4' , 103, 123),
                                                                          ('C4' ,'H41','C3' , 103, 123),
                                                                          ('C4' ,'H42','C3' , 103, 123) ] })
    ENGINE.add_constraints([IA_CONSTRAINT])
    IA_CONSTRAINT.create_angles_by_definition( anglesDefinition={"THF": [ ('C2','O','C1','C4', -15, 15),
                                                                          ('C3','O','C1','C4', -15, 15) ] })
    # initialize constraints data
    ENGINE.initialize_used_constraints()
    # set moves generators
    # set all move generators to Translation with a maximum amplutide of 0.3 A
    [g.set_move_generator(TranslationGenerator(amplitude=0.3)) for g in ENGINE.groups]
    # set randomly 25% of the translation amplitude to 10A
    [g.set_move_generator(TranslationGenerator(amplitude=10.)) for g in ENGINE.groups if np.random.random()>0.25]
    # return engine
    return ENGINE
Exemple #3
0
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
# files name
engineFileName = "engine.rmc"
grFileName = "experimental.gr"
sqFileName = "experimental.fq"
pdbFileName = "system.pdb"
# engine variables
grExpPath = os.path.join(DIR_PATH, grFileName)
sqExpPath = os.path.join(DIR_PATH, sqFileName)
pdbPath = os.path.join(DIR_PATH, pdbFileName)
engineFilePath = os.path.join(DIR_PATH, engineFileName)
# set some useful flags
FRESH_START = True

# check Engine exists, if not build it otherwise load it.
ENGINE = Engine(path=None)
if not ENGINE.is_engine(engineFilePath) or FRESH_START:
    # create engine
    ENGINE = Engine(path=engineFilePath, freshStart=True)
    ENGINE.set_pdb(pdbFileName)
    # add G(r) constraint
    PDF_CONSTRAINT = PairDistributionConstraint(experimentalData=grExpPath,
                                                weighting="atomicNumber")
    ENGINE.add_constraints([PDF_CONSTRAINT])
    # Rebin S(Q) experimental data and build constraint
    Sq = np.transpose(rebin(np.loadtxt(sqExpPath),
                            bin=0.05)).astype(FLOAT_TYPE)
    RSF_CONSTRAINT = ReducedStructureFactorConstraint(experimentalData=Sq,
                                                      weighting="atomicNumber")
    ENGINE.add_constraints([RSF_CONSTRAINT])
    # add coordination number constraint and set to un-used
Exemple #4
0
# standard libraries imports
import os

# fullrmc library imports
from fullrmc.Engine import Engine

# dirname
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
engineFilePath = os.path.join(DIR_PATH, "thf_engine.rmc")

# load
ENGINE = Engine(path=None)
result, mes = ENGINE.is_engine(engineFilePath, mes=True)
if result:
    ENGINE = ENGINE.load(engineFilePath)
    ENGINE.visualize(boxToCenter=True)
else:
    print mes
Exemple #5
0
# Create plotting styles
#styles  = ['-','--','-.',':']
colors = ["b", 'g', 'r', 'c', 'm', 'y']
markers = ["", '.', '+', '^', '|']
INTRA_STYLES = [r[0] + r[1] for r in itertools.product(['--'], colors)]
INTRA_STYLES = [r[0] + r[1] for r in itertools.product(markers, INTRA_STYLES)]
INTER_STYLES = [r[0] + r[1] for r in itertools.product(['-'], colors)]
INTER_STYLES = [r[0] + r[1] for r in itertools.product(markers, INTER_STYLES)]

trajectories = ["atomsTraj.xyz", "exploreTraj.xyz"]
pdbPath = "CO2.pdb"
expDataPath = "Xrays.gr"

# create engine
ENGINE = Engine(path=None)
ENGINE.set_pdb(pdbPath)
PDF_CONSTRAINT = PairDistributionConstraint(experimentalData=expDataPath,
                                            weighting="atomicNumber")
ENGINE.add_constraints([PDF_CONSTRAINT])
ENGINE.initialize_used_constraints()
ENGINE.set_chi_square()


def create_figure(PDF, show=False, savePath=None):
    # get output
    output = PDF.get_constraint_value()
    # create figure
    FIG = plt.figure()
    FIG.patch.set_facecolor('white')
    grid = gridspec.GridSpec(nrows=2, ncols=2)
Exemple #6
0
        # normalize vector
        vector /= FLOAT_TYPE(norm)
        # compute baseVector
        baseVector = FLOAT_TYPE(vector * self.amplitude[0])
        # amplify vector
        maxAmp = FLOAT_TYPE(self.amplitude[1] - self.amplitude[0])
        vector *= FLOAT_TYPE(generate_random_float() * maxAmp)
        vector += baseVector
        # translate and return
        return coordinates + vector


##########################################################################################
#####################################  CREATE ENGINE  ####################################
pdbPath = "system.pdb"
ENGINE = Engine(path=None)
ENGINE.set_pdb(pdbPath)
# add constraints
ACN_CONSTRAINT = AtomicCoordinationNumberConstraint()
ENGINE.add_constraints([ACN_CONSTRAINT])
ACN_CONSTRAINT.set_coordination_number_definition([
    ('Al', 'Cl', 1.5, 2.5, 2, 2), ('Al', 'S', 2.5, 3.0, 2, 2)
])
# add inter-molecular distance constraint
EMD_CONSTRAINT = InterMolecularDistanceConstraint(defaultDistance=1.0)
ENGINE.add_constraints([EMD_CONSTRAINT])
# set TranslationGenerator move generators amplitude
ENGINE.set_groups([[idx] for idx, el in enumerate(ENGINE.allElements)
                   if el != 'Al'])
[
    g.set_move_generator(XYTranslationGenerator(g, amplitude=0.1))
Exemple #7
0
from fullrmc.Engine import Engine
from fullrmc.Generators.Agitations import DistanceAgitationGenerator, AngleAgitationGenerator
from fullrmc.Selectors.OrderedSelectors import DefinedOrderSelector
from fullrmc.Constraints.BondConstraints import BondConstraint
from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint


##########################################################################################
##################################  SHUT DOWN LOGGING  ###################################
LOGGER.set_minimum_level(sys.maxint, stdoutFlag=True, fileFlag=True)


##########################################################################################
#####################################  CREATE ENGINE  ####################################
pdbPath = "waterBox.pdb"
ENGINE = Engine(path=None)
ENGINE.set_pdb( pdbPath  )

# add constraints
B_CONSTRAINT  = BondConstraint()
BA_CONSTRAINT = BondsAngleConstraint()
ENGINE.add_constraints([B_CONSTRAINT, BA_CONSTRAINT]) 
B_CONSTRAINT.create_bonds_by_definition( bondsDefinition={"TIP": [('OH2' ,'H1' , 0.8, 1.1),
                                                                  ('OH2' ,'H2' , 0.8, 1.1)] })
BA_CONSTRAINT.create_angles_by_definition( anglesDefinition={"TIP": [ ('OH2'  ,'H1' ,'H2' , 85, 120)] })

##########################################################################################
####################################  DIFFERENT RUNS  ####################################
def agitate_bonds():
    print "Agitate bonds"
    # agitate bonds
Exemple #8
0
from fullrmc.Constraints.BondConstraints import BondConstraint
from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint
from fullrmc.Constraints.ImproperAngleConstraints import ImproperAngleConstraint

##########################################################################################
##################################  SHUT DOWN LOGGING  ###################################
LOGGER.set_minimum_level(sys.maxint, stdoutFlag=True, fileFlag=True)

##########################################################################################
#####################################  CREATE ENGINE  ####################################
# parameters
NSTEPS = 10000
pdbPath = 'system.pdb'
expData = 'experimental.gr'
# initialize engine
ENGINE = Engine(path=None)
ENGINE.set_pdb(pdbPath)
# create constraints
PDF_CONSTRAINT = PairDistributionConstraint(experimentalData=expData,
                                            weighting="atomicNumber")
EMD_CONSTRAINT = InterMolecularDistanceConstraint()
B_CONSTRAINT = BondConstraint()
BA_CONSTRAINT = BondsAngleConstraint()
IA_CONSTRAINT = ImproperAngleConstraint()
# add constraints to engine
ENGINE.add_constraints([
    PDF_CONSTRAINT, EMD_CONSTRAINT, B_CONSTRAINT, BA_CONSTRAINT, IA_CONSTRAINT
])
# initialize constraints definitions
B_CONSTRAINT.create_bonds_by_definition(
    bondsDefinition={
Exemple #9
0
def run_engine(PDF=True,
               IMD=True,
               B=True,
               BA=True,
               IA=True,
               molecular=True,
               nsteps=10000,
               ncores=1):
    ENGINE = Engine(path=None)
    ENGINE.set_pdb(pdbPath)
    # create experimental constraints
    if PDF:
        C = PairDistributionConstraint(experimentalData=expPath,
                                       weighting="atomicNumber")
        ENGINE.add_constraints(C)
    # create and define molecular constraints
    if IMD:
        C = InterMolecularDistanceConstraint(defaultDistance=1.5)
        ENGINE.add_constraints(C)
    if B:
        C = BondConstraint()
        ENGINE.add_constraints(C)
        C.create_bonds_by_definition(
            bondsDefinition={
                "THF": [('O', 'C1', 1.29,
                         1.70), ('O', 'C4', 1.29,
                                 1.70), ('C1', 'C2', 1.29,
                                         1.70), ('C2', 'C3', 1.29,
                                                 1.70), ('C3', 'C4', 1.29,
                                                         1.70),
                        ('C1', 'H11', 0.58,
                         1.15), ('C1', 'H12', 0.58,
                                 1.15), ('C2', 'H21', 0.58,
                                         1.15), ('C2', 'H22', 0.58, 1.15),
                        ('C3', 'H31', 0.58,
                         1.15), ('C3', 'H32', 0.58,
                                 1.15), ('C4', 'H41', 0.58,
                                         1.15), ('C4', 'H42', 0.58, 1.15)]
            })
    if BA:
        C = BondsAngleConstraint()
        ENGINE.add_constraints(C)
        C.create_angles_by_definition(
            anglesDefinition={
                "THF": [
                    ('O', 'C1', 'C4', 95, 135),
                    ('C1', 'O', 'C2', 95, 135),
                    ('C4', 'O', 'C3', 95, 135),
                    ('C2', 'C1', 'C3', 90, 120),
                    ('C3', 'C2', 'C4', 90, 120),
                    # H-C-H angle
                    ('C1', 'H11', 'H12', 95, 125),
                    ('C2', 'H21', 'H22', 95, 125),
                    ('C3', 'H31', 'H32', 95, 125),
                    ('C4', 'H41', 'H42', 95, 125),
                    # H-C-O angle
                    ('C1', 'H11', 'O', 100, 120),
                    ('C1', 'H12', 'O', 100, 120),
                    ('C4', 'H41', 'O', 100, 120),
                    ('C4', 'H42', 'O', 100, 120),
                    # H-C-C
                    ('C1', 'H11', 'C2', 80, 123),
                    ('C1', 'H12', 'C2', 80, 123),
                    ('C2', 'H21', 'C1', 80, 123),
                    ('C2', 'H21', 'C3', 80, 123),
                    ('C2', 'H22', 'C1', 80, 123),
                    ('C2', 'H22', 'C3', 80, 123),
                    ('C3', 'H31', 'C2', 80, 123),
                    ('C3', 'H31', 'C4', 80, 123),
                    ('C3', 'H32', 'C2', 80, 123),
                    ('C3', 'H32', 'C4', 80, 123),
                    ('C4', 'H41', 'C3', 80, 123),
                    ('C4', 'H42', 'C3', 80, 123)
                ]
            })
    if IA:
        C = ImproperAngleConstraint()
        ENGINE.add_constraints(C)
        C.create_angles_by_definition(
            anglesDefinition={
                "THF": [('C2', 'O', 'C1', 'C4', -15,
                         15), ('C3', 'O', 'C1', 'C4', -15, 15)]
            })
    # initialize constraints data
    ENGINE.initialize_used_constraints()
    # run engine
    if molecular:
        ENGINE.set_groups_as_molecules()
        print 'molecular, %s atoms, %s steps, %2s cores' % (
            ENGINE.numberOfAtoms, nsteps, ncores),
        tic = time.time()
        ENGINE.run(numberOfSteps=nsteps,
                   saveFrequency=2 * nsteps,
                   restartPdb=None,
                   ncores=ncores)
        elapsed = float(time.time() - tic) / float(nsteps)
        print ' -- > %s seconds per step' % (elapsed, )
    else:
        ENGINE.set_groups_as_atoms()
        print 'atomic   , %s atoms, %s steps, %2s cores' % (
            ENGINE.numberOfAtoms, nsteps, ncores),
        tic = time.time()
        ENGINE.run(numberOfSteps=nsteps,
                   saveFrequency=2 * nsteps,
                   restartPdb=None,
                   ncores=ncores)
        elapsed = float(time.time() - tic) / float(nsteps)
        print ' -- > %s seconds per step' % (elapsed, )
        # return elapsed time
    return elapsed
Exemple #10
0
# fullrmc library imports
from fullrmc.Globals import LOGGER
from fullrmc.Engine import Engine
from fullrmc.Core.MoveGenerator import MoveGeneratorCollector
from fullrmc.Constraints.DistanceConstraints import InterMolecularDistanceConstraint
from fullrmc.Generators.Rotations import RotationGenerator
from fullrmc.Generators.Translations import TranslationTowardsCenterGenerator

##########################################################################################
##################################  SHUT DOWN LOGGING  ###################################
LOGGER.set_minimum_level(sys.maxint, stdoutFlag=True, fileFlag=True)

##########################################################################################
#####################################  CREATE ENGINE  ####################################
pdbPath = "system.pdb"
ENGINE = Engine(path=None)
ENGINE.set_pdb(pdbPath)
# add inter-molecular distance constraint
EMD_CONSTRAINT = InterMolecularDistanceConstraint(defaultDistance=1.75)
ENGINE.add_constraints([EMD_CONSTRAINT])


##########################################################################################
####################################  DIFFERENT RUNS  ####################################
def move_towards():
    # set only one molecule group
    ENGINE.set_groups_as_molecules()
    secMolIdxs = ENGINE.groups[1].indexes
    ENGINE.set_groups(ENGINE.groups[0])
    # set move generator
    for g in ENGINE.groups:
Exemple #11
0
from fullrmc.Globals import LOGGER, maxint
from fullrmc.Engine import Engine
from fullrmc.Constraints.BondConstraints import BondConstraint
from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint
from fullrmc.Constraints.DihedralAngleConstraints import DihedralAngleConstraint


##########################################################################################
##################################  SHUT DOWN LOGGING  ###################################
LOGGER.set_minimum_level(maxint, stdoutFlag=True, fileFlag=True)


##########################################################################################
#####################################  CREATE ENGINE  ####################################
pdbPath = "system.pdb"
ENGINE = Engine(path=None)
ENGINE.set_pdb(pdbPath)

# add constraints
B_CONSTRAINT   = BondConstraint()
BA_CONSTRAINT  = BondsAngleConstraint()
DA_CONSTRAINT  = DihedralAngleConstraint()
ENGINE.add_constraints([B_CONSTRAINT, BA_CONSTRAINT, DA_CONSTRAINT])
B_CONSTRAINT.create_bonds_by_definition( bondsDefinition={"BUT": [# C-C bonds
                                                                  ('C1' ,'C2' , 1.33, 1.73),
                                                                  ('C2' ,'C3' , 1.33, 1.73),
                                                                  ('C3' ,'C4' , 1.33, 1.73),
                                                                  # C-H3 bonds
                                                                  ('C1' ,'H11', 1.01, 1.21),
                                                                  ('C1' ,'H12', 1.01, 1.21),
                                                                  ('C1' ,'H13', 1.01, 1.21),
Exemple #12
0
##########################################################################################
#####################################  CREATE ENGINE  ####################################
# dirname
DIR_PATH = os.path.dirname(os.path.realpath(__file__))

# engine file names
engineFileName = "thf_engine.rmc"
expFileName = "thf_pdf.exp"
pdbFileName = "thf.pdb"
freshStart = False

# engine variables
expPath = os.path.join(DIR_PATH, expFileName)
pdbPath = os.path.join(DIR_PATH, pdbFileName)
engineFilePath = os.path.join(DIR_PATH, engineFileName)
ENGINE = Engine(path=None)
if freshStart or not ENGINE.is_engine(engineFilePath):
    # create engine
    ENGINE = Engine(path=engineFilePath, freshStart=True)
    ENGINE.set_pdb(pdbFileName)
    ## create experimental constraints
    #PDF_CONSTRAINT = PairDistributionConstraint(experimentalData=expPath, weighting="atomicNumber")
    _, _, _, gr = convert_Gr_to_gr(np.loadtxt(expPath), minIndex=[4, 5, 6])
    dataWeights = np.ones(gr.shape[0])
    dataWeights[:np.nonzero(gr[:, 1] > 0)[0][0]] = 0
    PDF_CONSTRAINT = PairCorrelationConstraint(
        experimentalData=gr.astype(FLOAT_TYPE),
        weighting="atomicNumber",
        dataWeights=dataWeights)
    # create and define molecular constraints
    EMD_CONSTRAINT = InterMolecularDistanceConstraint(defaultDistance=1.5)
Exemple #13
0
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
# files name
engineFileName = "engine.rmc"
grFileName = "experimental.gr"
sqFileName = "experimental.fq"
pdbFileName = "system.pdb"
# engine variables
grExpPath = os.path.join(DIR_PATH, grFileName)
sqExpPath = os.path.join(DIR_PATH, sqFileName)
pdbPath = os.path.join(DIR_PATH, pdbFileName)
engineFilePath = os.path.join(DIR_PATH, engineFileName)
# set some useful flags
FRESH_START = False

# check Engine exists, if not build it otherwise load it.
ENGINE = Engine(path=None)
if not ENGINE.is_engine(engineFilePath) or FRESH_START:
    # create engine
    ENGINE = Engine(path=engineFilePath, freshStart=True)
    ENGINE.set_pdb(pdbFileName)
    # add G(r) constraint
    PDF_CONSTRAINT = PairDistributionConstraint(experimentalData=grExpPath,
                                                weighting="atomicNumber")
    ENGINE.add_constraints([PDF_CONSTRAINT])
    # Rebin S(Q) experimental data and build constraint
    Sq = np.transpose(rebin(np.loadtxt(sqExpPath),
                            bin=0.05)).astype(FLOAT_TYPE)
    RSF_CONSTRAINT = ReducedStructureFactorConstraint(experimentalData=Sq,
                                                      weighting="atomicNumber")
    ENGINE.add_constraints([RSF_CONSTRAINT])
    # add coordination number constraint and set to un-used
Exemple #14
0
from fullrmc.Core.Group import EmptyGroup
from fullrmc.Constraints.PairDistributionConstraints import PairDistributionConstraint
from fullrmc.Constraints.DistanceConstraints import InterMolecularDistanceConstraint
from fullrmc.Generators.Translations import TranslationGenerator
from fullrmc.Generators.Swaps import SwapPositionsGenerator

#  ####################################################################################  #
#  ############################# DECLARE USEFUL VARIABLES #############################  #
experimentalDataPath = "pdf.exp"
structurePdbPath = "system.pdb"
engineSavePath = "system.rmc"
FRESH_START = False

#  ####################################################################################  #
#  ################################### CREATE ENGINE ##################################  #
ENGINE = Engine(path=None)
if not ENGINE.is_engine(engineSavePath) or FRESH_START:
    ENGINE = Engine(path=engineSavePath, freshStart=True)
    ENGINE.set_pdb(structurePdbPath)
    ## create and add pair distribution constraint
    PDF_CONSTRAINT = PairDistributionConstraint(
        experimentalData=experimentalDataPath, weighting="atomicNumber")
    ENGINE.add_constraints([PDF_CONSTRAINT])
    ## create and add intermolecular distances constraint
    EMD_CONSTRAINT = InterMolecularDistanceConstraint()
    ENGINE.add_constraints([EMD_CONSTRAINT])
    EMD_CONSTRAINT.set_type_definition("element")
    EMD_CONSTRAINT.set_pairs_distance([
        ('Co', 'Co', 2.00),
        ('Co', 'Mn', 2.00),
        ('Co', 'Ni', 2.00),
Exemple #15
0

# files name
grFileName     = "SiOx.gr"
pdbFileName    = "SiOx.pdb"
engineFileName = "SiOx.rmc"
multiframe     = 'size_distribution'
numberOfFrames = 10
FRESH_START    = False
# engine variables
grExpPath      = os.path.join(DIR_PATH, grFileName)
pdbPath        = os.path.join(DIR_PATH, pdbFileName)
engineFilePath = os.path.join(DIR_PATH, engineFileName)


ENGINE = Engine(path=None)
if not ENGINE.is_engine(engineFilePath) or FRESH_START:
   # create engine
    ENGINE = Engine(path=engineFilePath, freshStart=True)
    ENGINE.set_pdb(pdbPath)
    # create and add pair distribution constraint to the engine
    PDF_CONSTRAINT = PairDistributionConstraint(experimentalData=grExpPath, weighting="atomicNumber")
    # shape function parameters
    params = {'rmin':0., 'rmax':None, 'dr':0.5,
              'qmin':0.0001, 'qmax':0.6, 'dq':0.005,
              'updateFreq':1000}
    PDF_CONSTRAINT.set_shape_function_parameters(params)
    ENGINE.add_constraints([PDF_CONSTRAINT])
    # Intermolecular constraint
    EMD_CONSTRAINT = InterMolecularDistanceConstraint()
    ENGINE.add_constraints([EMD_CONSTRAINT])
Exemple #16
0
# standard libraries imports
import os
import itertools

# external libraries imports
import matplotlib.pyplot as plt

# fullrmc library imports
from fullrmc.Engine import Engine
from fullrmc.Constraints.PairCorrelationConstraints import PairDistributionConstraint

ENGINE = Engine(path=None)
ENGINE.set_pdb('system.pdb')
PDF_CONSTRAINT = PairDistributionConstraint(experimentalData="experimental.gr",
                                            weighting="atomicNumber")
ENGINE.add_constraints([PDF_CONSTRAINT])

# Create plotting styles
colors = ["b", 'g', 'r', 'c', 'm', 'y']
markers = ["", '.', '+', '^', '|']
STYLE = [r[0] + r[1] for r in itertools.product(['-'], colors)]
STYLE = [r[0] + r[1] for r in itertools.product(markers, STYLE)]


def plot(PDF, figName, imgpath, show=False, save=True):
    # plot
    output = PDF.get_constraint_value()
    plt.plot(PDF.experimentalDistances,
             PDF.experimentalPDF,
             'ro',
             label="experimental",
Exemple #17
0
else:
    data = {}

# compute pdfs
dataAdded = False
for idx in range(len(pdbFiles)):
    fname = pdbFiles[idx]
    if fname in data: continue
    dataAdded = True
    print("loading frame %i out of %i --> %s" % (idx, len(pdbFiles), fname))
    # create constraints
    PDF = PairDistributionConstraint(engine=None,
                                     experimentalData=expDataPath,
                                     weighting="atomicNumber")
    # create engine
    ENGINE = Engine(pdb=fname, constraints=[PDF])
    ENGINE.run(numberOfSteps=0)
    # get pdf
    output = PDF.get_constraint_value()
    output["observed"] = PDF.experimentalPDF
    output["observedR"] = PDF.experimentalDistances
    output["computedR"] = PDF.shellsCenter
    output["chiSquare"] = PDF.squaredDeviations
    data[fname] = output

if dataAdded: pickle.dump(data, open(pdfDataPath, "wb"))

# plot data
idx = 0
for key in pdbFiles:
    #key = pdbFiles[-1]
Exemple #18
0
import numpy as np

# fullrmc library imports
from fullrmc.Globals import LOGGER
from fullrmc.Engine import Engine
from fullrmc.Constraints.BondConstraints import BondConstraint
from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint

##########################################################################################
##################################  SHUT DOWN LOGGING  ###################################
LOGGER.set_minimum_level(sys.maxint, stdoutFlag=True, fileFlag=True)

##########################################################################################
#####################################  CREATE ENGINE  ####################################
pdbPath = "system.pdb"
ENGINE = Engine(path=None)
ENGINE.set_pdb(pdbPath)

# add constraints
B_CONSTRAINT = BondConstraint()
BA_CONSTRAINT = BondsAngleConstraint()
ENGINE.add_constraints([B_CONSTRAINT, BA_CONSTRAINT])
B_CONSTRAINT.create_bonds_by_definition(bondsDefinition={
    "TIP": [('OH2', 'H1', 0.8, 1.1), ('OH2', 'H2', 0.8, 1.1)]
})
BA_CONSTRAINT.create_angles_by_definition(
    anglesDefinition={"TIP": [('OH2', 'H1', 'H2', 80, 120)]})

# set TranslationGenerator move generators amplitude
[g.moveGenerator.set_amplitude(0.025) for g in ENGINE.groups]
Exemple #19
0
# external libraries imports

# fullrmc library imports
from fullrmc.Globals import LOGGER
from fullrmc.Engine import Engine
from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutAxisGenerator, RotationAboutSymmetryAxisGenerator
from fullrmc.Core.Collection import get_principal_axis

##########################################################################################
###################################  SHUT DOWN LOGGING  ##################################
LOGGER.set_minimum_level(sys.maxint, stdoutFlag=True, fileFlag=True)

##########################################################################################
#####################################  CREATE ENGINE  ####################################
pdbPath = "molecule.pdb"
ENGINE = Engine(path=None)
ENGINE.set_pdb(pdbPath)

# set groups as the whole molecule
ENGINE.set_groups_as_molecules()

nsteps = 500
xyzFrequency = 1


##########################################################################################
#####################################  DIFFERENT RUNS  ###################################
def about_axis_0():
    # run engine rotation about axis 0
    xyzPath = "about0.xyz"
    if os.path.isfile(xyzPath): os.remove(xyzPath)
Exemple #20
0
# Create plotting styles
#styles  = ['-','--','-.',':']
colors = ["b",'g','r','c','m','y']
markers = ["",'.','+','^','|']
INTRA_STYLES = [r[0] + r[1]for r in itertools.product(['--'], colors)]
INTRA_STYLES = [r[0] + r[1]for r in itertools.product(markers, INTRA_STYLES)]
INTER_STYLES = [r[0] + r[1]for r in itertools.product(['-'], colors)]
INTER_STYLES = [r[0] + r[1]for r in itertools.product(markers, INTER_STYLES)]


# dirname
DIR_PATH = os.path.dirname( os.path.realpath(__file__) )
engineFilePath = os.path.join(DIR_PATH, "CO2.rmc")

# load
ENGINE = Engine(path=None)
result, mes = ENGINE.is_engine(engineFilePath, mes=True)
if not result:
    print mes
    exit()
    
# load engine and get pdf constraint engine
ENGINE = ENGINE.load(engineFilePath)
PDF_CONSTRAINT = ENGINE.constraints[0]

def create_figure(PDF):
    # get output
    output = PDF.get_constraint_value()
    # create figure
    FIG = plt.figure()
    FIG.patch.set_facecolor('white')
Exemple #21
0
#####################################  CREATE ENGINE  ####################################
# dirname
DIR_PATH = os.path.dirname( os.path.realpath(__file__) )
# files name
grFileName     = "SiOx.gr"
pdbFileName    = "SiOx.pdb"
engineFileName = "SiOx.rmc"
NCORES         = 1
FRESH_START    = False
# engine variables
grExpPath      = os.path.join(DIR_PATH, grFileName)
pdbPath        = os.path.join(DIR_PATH, pdbFileName)
engineFilePath = os.path.join(DIR_PATH, engineFileName)


ENGINE = Engine(path=None)
if not ENGINE.is_engine(engineFilePath) or FRESH_START:
   # create engine
    ENGINE = Engine(path=engineFilePath, freshStart=True)
    ENGINE.set_pdb(pdbPath)
    # create and add pair distribution constraint to the engine
    PDF_CONSTRAINT = PairDistributionConstraint(experimentalData=grExpPath, weighting="atomicNumber")
    # shape function parameters
    params = {'rmin':0., 'rmax':None, 'dr':0.5,
              'qmin':0.0001, 'qmax':0.6, 'dq':0.005,
              'updateFreq':1000}
    PDF_CONSTRAINT.set_shape_function_parameters(params)
    ENGINE.add_constraints([PDF_CONSTRAINT])
    # Intermolecular constraint
    EMD_CONSTRAINT = InterMolecularDistanceConstraint()
    ENGINE.add_constraints([EMD_CONSTRAINT])