コード例 #1
0
ファイル: engine2.py プロジェクト: mastricker/pypospack
    def write_eam_setfl_file(self,parameters,potential,setfl_fn):

        from pypospack.potential import EamPotential
        is_debug = False

        assert isinstance(parameters,OrderedDict)
        assert isinstance(potential,OrderedDict)
        assert isinstance(setfl_fn,str)

        if is_debug:
            print(parameters)
            print(potential)
            print(setfl_fn)

        p = EamPotential(
                symbols=potential['symbols'],
                func_pair=potential['pair_type'],
                func_density=potential['density_type'],
                func_embedding=potential['embedding_type']
        )
        p.write_setfl_file(
                filename=setfl_fn,
                symbols=potential['symbols'],
                Nr=potential['N_r'],
                rmax=potential['r_max'],
                rcut=potential['r_cut'],
                Nrho=potential['N_rho'],
                rhomax=potential['rho_max'],
                parameters=parameters
        )
コード例 #2
0
def test__evaluate():

    pot = EamPotential(symbols=symbols,
            func_pair=func_pair_name,
            func_density=func_density_name,
            func_embedding=func_embedding_name)
    pot.evaluate(
            r = r,
            rho = rho,
            rcut = r_max,
            parameters = parameters)
コード例 #3
0
def test____init__():
    obj_pot = EamPotential(symbols=symbols,
                           func_pair=func_pair_name,
                           func_density=func_density_name,
                           func_embedding=func_embedding_name)

    assert type(obj_pot) is EamPotential
    assert obj_pot.potential_type == 'eam'
    assert type(obj_pot.symbols) is list
    assert len(obj_pot.symbols) == len(symbols)
    for i, v in enumerate(symbols):
        obj_pot.symbols[i] = v

    assert obj_pot.is_charge is False
    assert type(obj_pot.parameter_names) is list
    assert len(obj_pot.parameter_names) == len(expected_parameter_names)
    for i, v in enumerate(expected_parameter_names):
        obj_pot.parameter_names = v
コード例 #4
0
def test__init__():

    pot = EamPotential(symbols=symbols,
            func_pair=func_pair_name,
            func_density=func_density_name,
            func_embedding=func_embedding_name)

    assert pot.potential_type == 'eam'
    assert pot.is_charge is False

    assert pot.symbols == symbols

    assert type(pot.obj_pair) is BornMayerPotential
    assert type(pot.obj_embedding) is RoseEquationOfStateEmbeddingFunction
    assert type(pot.obj_density) is ExponentialDensityFunction

    assert pot.obj_pair.parameter_names == parameter_names_pair
    assert pot.obj_embedding.parameter_names == parameter_names_embedding
    assert pot.obj_density.parameter_names == parameter_names_density
コード例 #5
0
V = a0**3
lattice_info['Ni']['equilibrium_volume_per_atom'] = V

re = 1/(2**0.5)*a0
lattice_info['Ni']['equilibrium_interatomic_distance'] = 1/(2**0.5)*a0 

print(80*'-')
print("func_pair_name={}".format(func_pair_name))
print("func_density_name={}".format(func_density_name))
print("func_embedding_name={}".format(func_embedding_name))
print(80*'-')

# CONSTRUCTOR TEST

pot = EamPotential(symbols=symbols,
       func_pair=func_pair_name, 
       func_density=func_density_name,
       func_embedding=func_embedding_name)

print('pot.potential_type == {}'.format(\
    pot.potential_type))
print('pot.obj_density == {}'.format(
    type(pot.obj_density)))
print('pot.obj_pair_fn == {}'.format(
    type(pot.obj_pair)))
print('pot.obj_embedding_fn == {}'.format(
    type(pot.obj_embedding)))
print('pot.symbols == {}'.format(\
        pot.symbols))
print('pot.parameter_names == {}'.format(\
        pot.parameter_names))
print('pot.is_charge == {}'.format(\
コード例 #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from collections import OrderedDict

import numpy as np

import pypospack.utils
from pypospack.eamtools import SeatonSetflReader
from pypospack.potential import EamPotential

setfl_filename = os.path.join(
        pypospack.utils.get_pypospack_root_directory(),
        'data','potentials','Ni__eam','Mishin-Ni-Al-2009.eam.alloy')

setfl_reader = SeatonSetflReader(path=setfl_filename)
setfl_reader.read()


density_types = ['eam_dens_exp','eam_dens_mishin']
embedding_types = ['eam_embed_universal','eam_embed_bjs']

o_potential = EamPotential(symbols=['Ni','Al'],
        func_pair=)

コード例 #7
0
    (nrows, ncols) = datafile.df.shape

    normederr_names = ['{}.nerr'.format(q) for q in datafile.qoi_names]

    datafile.df['d_metric'] = np.sqrt(
        np.square(datafile.df[normederr_names]).sum(axis=1))
    subselect_df = datafile.df.nsmallest(1, "d_metric")
    subselect_df.set_index("sim_id")

    symbols = ["Ni"]
    func_pair_name = "bornmayer"
    func_density_name = "eam_dens_exp"
    func_embedding_name = "eam_embed_fs"

    eam_potential = EamPotential(symbols=symbols,
                                 func_pair=func_pair_name,
                                 func_density=func_density_name,
                                 func_embedding=func_embedding_name)

    parameters = OrderedDict()
    for name in datafile.parameter_names:
        parameters[name] = subselect_df[name].values[0]

    # plotting portion copied from pypospack.tests.tests_integration.eamtools.EamSetflFile.dev_EamSetflFile

    setfl_fn = "Ni__eam__born_exp_fs.eam.alloy"
    n_r = 2000
    r_max = 10.0
    r_cut = 10.0
    n_rho = 2000
    rho_max = 10.0
コード例 #8
0
ファイル: eam_potential.py プロジェクト: mastricker/pypospack
# configuration inforamtion
symbols = ['Ni']

#<--- variables unique for the test ---------------------------------------
symbols = ['Ni']
func_pair='morse'
func_density='eam_dens_exp'
func_embedding='eam_embed_universal'

#<--- setup of the code to conduct the test -------------------------------
from pypospack.potential import EamPotential

#<--- code being tested ---------------------------------------------------
eam_pot = EamPotential(
        symbols=symbols,
        func_pair=func_pair,
        func_density=func_density,
        func_embedding=func_embedding)

lattice_info = OrderedDict()
lattice_info['Ni'] = OrderedDict()
lattice_info['Ni']['a0'] = 3.524 # in Angs
lattice_info['Ni']['lattice_type'] = 'fcc'

# create parameter diction
parameters = OrderedDict()
parameters['p_NiNi_D0'] = 1.
parameters['p_NiNi_a'] = 1
parameters['p_NiNi_r0'] = 1
parameters['d_Ni_rho0'] = 1. 
parameters['d_Ni_beta'] = 1
コード例 #9
0
from pypospack.potential import RoseEquationOfStateEmbeddingFunction
o_embed_fn = RoseEquationOfStateEmbeddingFunction(symbols=symbols)
func_pair_name = "morse"
func_density_name = "eam_dens_exp"
func_embedding_name = "eam_embed_eos_rose"

print(80 * '-')
print("func_pair_name={}".format(func_pair_name))
print("func_density_name={}".format(func_density_name))
print("func_embedding_name={}".format(func_embedding_name))
print(80 * '-')

# CONSTRUCTOR TEST

pot = EamPotential(symbols=symbols,
                   func_pair=func_pair_name,
                   func_density=func_density_name,
                   func_embedding=func_embedding_name)

print('pot.potential_type == {}'.format(\
    pot.potential_type))
print('pot.obj_density == {}'.format(type(pot.obj_density)))
print('pot.obj_pair_fn == {}'.format(type(pot.obj_pair)))
print('pot.obj_embedding_fn == {}'.format(type(pot.obj_embedding)))
print('pot.symbols == {}'.format(\
        pot.symbols))
print('pot.parameter_names == {}'.format(\
        pot.parameter_names))
print('pot.is_charge == {}'.format(\
        pot.is_charge))
print('pot.param == {}'.format(\
        pot.param))
コード例 #10
0
configuration = OrderedDict()
configuration['potential'] = Ni_eam_potential_definition
configuration['parameters'] = Ni_eam_parameters

#<------------- unpack dictionary
symbols = configuration['potential']['symbols']
func_pair = configuration['potential']['pair_type']
func_density = configuration['potential']['density_type']
func_embedding = configuration['potential']['embedding_type']

parameters = configuration['parameters']
#<------------ setup for testing
from pypospack.potential import EamPotential
eam = EamPotential(
        symbols=symbols,
        func_pair=func_pair,
        func_density=func_density,
        func_embedding=func_embedding)

a0 = 3.50803
sites = ['T','O','1NN','2NN','3NN']
N = OrderedDict()
N['T'] = 4
N['O'] = 4
N['1NN'] = 12
N['2NN'] = 6
N['3NN'] = 24
da = OrderedDict()
da['T'] = 0.433
da['O'] = 0.866
da['1NN']= 0.707
コード例 #11
0
def test_2sym____init____morse_exponential_universal():
    #<--- variables unique for the test ---------------------------------------
    symbols = ['Ni','Al']
    func_pair='morse'
    func_density='eam_dens_exp'
    func_embedding='eam_embed_universal'

    #<--- setup of the code to conduct the test -------------------------------
    from pypospack.potential import EamPotential

    #<--- code being tested ---------------------------------------------------
    eam = EamPotential(
            symbols=symbols,
            func_pair=func_pair,
            func_density=func_density,
            func_embedding=func_embedding)
    from pypospack.potential import EamPotential

    eam = EamPotential(
            symbols=symbols,
            func_pair='morse',
            func_density='eam_dens_exp',
            func_embedding='eam_embed_universal')

    #<--- setup testing
    from pypospack.potential import MorsePotential
    from pypospack.potential import ExponentialDensityFunction
    from pypospack.potential import UniversalEmbeddingFunction
    pair = MorsePotential(symbols=symbols)
    dens = ExponentialDensityFunction(symbols=symbols)
    embed = UniversalEmbeddingFunction(symbols=symbols)

    p_names = ["p_{}".format(p) for p in pair.parameter_names]
    d_names = ["d_{}".format(p) for p in dens.parameter_names]
    e_names = ["e_{}".format(p) for p in embed.parameter_names]
    parameter_names = p_names + d_names + e_names
    
    #<--- testing attributes
    # All public attributes and properties should be tested for expected
    # behavior.  This includes all attributes and properties which are 
    # initialized to None after class constructor is called
    #<------ testing eam.obj_pair is inherited from the correct base class
    from pypospack.potential import PairPotential
    assert isinstance(eam.obj_pair,PairPotential)
    
    #<------ testing eam.obj_density is inherited from the correct base class
    from pypospack.potential import EamDensityFunction
    assert isinstance(eam.obj_density,EamDensityFunction)
    
    #<------ testing eam.obj_embedding is inherited from correct base class
    from pypospack.potential import EamEmbeddingFunction
    assert isinstance(eam.obj_embedding,EamEmbeddingFunction)
    
    #<------ testing eam.symbols
    assert type(eam.symbols) is list
    assert eam.symbols == symbols

    #<------ testing eam.parameter_names
    assert type(eam.parameter_names) is list
    assert len(eam.parameter_names) == len(parameter_names)
    for pn in parameter_names:
        pn in eam.parameter_names
    
    #<------ testing eam.parameters
    assert type(eam.parameters) is OrderedDict
    assert len(eam.parameters) == len(eam.parameter_names)
    for pn in eam.parameter_names:
        assert pn in eam.parameters
    for pn,pv in eam.parameters.items():
        assert pv is None

    #<------ testing attributes should be set to None
    assert eam.pair == None
    assert eam.density == None
    assert eam.embedding == None