示例#1
0
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),
        ('Co', 'Li', 2.00),
示例#2
0
#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')
    grid = gridspec.GridSpec(nrows=2, ncols=2)
示例#3
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)
    B_CONSTRAINT = BondConstraint()