Exemple #1
0
m0 = asap3.heap_mallinfo()
if m0 < 0:
    print "Memory monitoring not supported, test skipped."
else:
    print "Memory at startup", m0, 'kB'
    
    for throwexception in (False, True):
        for replacepotential in (False, True):
            for replaceatoms in (False, True):
                print ("Running test: ReplacePotential=%s ReplaceAtoms=%s Exception=%s"
                       % (replacepotential, replaceatoms, throwexception))
                leak = 0
                if not replaceatoms:
                    atoms = makeatoms(throwexception)
                if not replacepotential:
                    pot = asap3.EMT()
                for i in range(steps):
                    if replaceatoms:
                        atoms = makeatoms(throwexception)
                    if replacepotential:
                        pot = asap3.EMT()
                    if i == 0 or replaceatoms or replacepotential:
                        atoms.set_calculator(pot)
                    try:
                        e = atoms.get_potential_energy()
                        #f = atoms.get_forces()
                    except asap3.AsapError:
                        pass
                    m = int(asap3.heap_mallinfo())
                    if i == msteps:
                        m0 = m
Exemple #2
0
def ASAPCalculator(model_name, model_type, options, **kwargs):
    """
    Can be used with either Portable Models or Simulator Models
    """
    import asap3

    options_not_allowed = {"pm": ["name", "verbose"], "sm": ["Params"]}

    _check_conflict_options(options,
                            options_not_allowed[model_type],
                            simulator="asap")

    if model_type == "pm":

        return asap3.OpenKIMcalculator(name=model_name,
                                       verbose=kwargs["verbose"],
                                       **options)

    elif model_type == "sm":
        model_defn = kwargs["model_defn"]
        supported_units = kwargs["supported_units"]

        # Verify units (ASAP models are expected to work with "ase" units)
        if supported_units != "ase":
            raise KIMCalculatorError(
                'KIM Simulator Model units are "{}", but expected to '
                'be "ase" for ASAP.'.format(supported_units))

        # Check model_defn to make sure there's only one element in it that is a
        # non-empty string
        if len(model_defn) == 0:
            raise KIMCalculatorError(
                "model-defn is an empty list in metadata file of Simulator Model {}"
                "".format(model_name))
        elif len(model_defn) > 1:
            raise KIMCalculatorError(
                "model-defn should contain only one entry for an ASAP model (found {} "
                "lines)".format(len(model_defn)))

        if "" in model_defn:
            raise KIMCalculatorError(
                "model-defn contains an empty string in metadata file of Simulator "
                "Model {}".format(model_name))

        model_defn = model_defn[0].strip()

        # Instantiate calculator from ASAP.  Currently, this must be one of:
        # (1) EMT
        # (2) EMT(EMTRasmussenParameters)
        # (3) EMT(EMTMetalGlassParameters)
        model_defn_is_valid = False
        if model_defn.startswith("EMT"):
            # Pull out potential parameters
            mobj = re.search(r"\(([A-Za-z0-9_\(\)]+)\)", model_defn)
            if mobj is None:
                asap_calc = asap3.EMT()
            else:
                pp = mobj.group(1)

                # Currently we only supported two specific EMT models that are built
                # into ASAP
                if pp.startswith("EMTRasmussenParameters"):
                    asap_calc = asap3.EMT(
                        parameters=asap3.EMTRasmussenParameters())
                    model_defn_is_valid = True
                elif pp.startswith("EMTMetalGlassParameters"):
                    asap_calc = asap3.EMT(
                        parameters=asap3.EMTMetalGlassParameters())
                    model_defn_is_valid = True

        if not model_defn_is_valid:
            raise KIMCalculatorError(
                'Unknown model "{}" requested for simulator asap.'.format(
                    model_defn))

        # Disable undocumented feature for the EMT self.calculators to take the
        # energy of an isolated atoms as zero. (Otherwise it is taken to be that of
        # perfect FCC.)
        asap_calc.set_subtractE0(False)

        return asap_calc
Exemple #3
0
elif world.size == 3:
    cpulayout = [1,3,1]
elif world.size == 4:
    cpulayout = [1,2,2]

print_version(1)

if ismaster:
    atoms = FaceCenteredCubic(size=(2,10,10), symbol="Cu", pbc=False,
                              latticeconstant = 3.5)
else:
    atoms = None

if isparallel:
    atoms = MakeParallelAtoms(atoms, cpulayout)
atoms.set_calculator(asap3.EMT())
natoms = atoms.get_number_of_atoms()
    
ReportTest("Number of atoms", natoms, 800, 0)

# Make a small perturbation of the momenta
atoms.set_momenta(1e-6 * random.random([len(atoms), 3]))
print "Initializing ..."
predyn = VelocityVerlet(atoms, 0.5)
try:
    predyn.run(2500)
except:
    print atoms.arrays['positions']
    print atoms.arrays['momenta']
    print atoms.arrays['momenta'].shape
    print atoms.get_masses()