Convert AMS Text Input or Run File to PLAMS Format#
Downloads: Notebook | Script ?
Requires: AMS2027 or later
Related tutorials
Related documentation
Convert AMS text input to Python code that builds an input model#
Input models are the recommended way to define AMS input from Python. Any AMS text input can be turned into an input model with from_input, and to_python then returns the Python code that rebuilds it, as an import block and a body. This is the quickest way to find out how a block or key you already know from the text input is spelled in Python.
inp = """
Task GeometryOptimization
GeometryOptimization
MaxIterations 10000
PretendConverged Yes
End
Engine ADF
Basis
Type DZP
End
XC
GGA PBE
End
Solvation
C-Mat Potential
Charged Method=Conjugate-Gradient
SCF Variational
Solv Epsilon=78.4 Radius=1.4 Cav0=1.321 Cav1=0.0067639
Surf Delley
End
EndEngine
"""
from scm.inputs import AMS
imports, body = AMS.from_input(inp).to_python()
print(imports)
print()
print(body)
from scm.inputs import ADF, AMS
input_model = AMS()
input_model.Task = 'GeometryOptimization'
adf = ADF()
adf.Basis.Type = 'DZP'
adf.XC.GGA = 'PBE'
adf.Solvation.Surf = 'delley'
adf.Solvation.Solv = 'Epsilon=78.4 Radius=1.4 Cav0=1.321 Cav1=0.0067639'
adf.Solvation.Charged = 'Method=Conjugate-Gradient'
adf.Solvation.SCF = 'Variational'
adf.Solvation.C_Mat = 'Potential'
input_model.Engine = adf
input_model.GeometryOptimization.MaxIterations = 10000
input_model.GeometryOptimization.PretendConverged = True
Convert AMS text input to a Settings object#
PLAMS also still accepts its own Settings objects. AMSJob.from_input parses AMS text input into the equivalent Settings, which is useful when maintaining older scripts.
A complete run script, as written by AMSinput, can be converted into a ready to run PLAMS script with $AMSBIN/amspython -m scm.utils.convert_run_to_plams myjob.run myjob.py. That is the same conversion that File → Export PLAMS script… performs in AMSinput, and it writes a script that builds an input model.
from scm.plams import AMSJob
settings = AMSJob.from_input(inp).settings
print(f"{type(settings)=}")
print(settings)
type(settings)=<class 'scm.plams.core.settings.Settings'>
input:
ADF:
Basis:
Type: DZP
Solvation:
C-Mat: Potential
Charged: Method=Conjugate-Gradient
SCF: Variational
Solv: Epsilon=78.4 Radius=1.4 Cav0=1.321 Cav1=0.0067639
Surf: delley
XC:
GGA: PBE
ams:
Task: GeometryOptimization
on_status_change: <empty Settings>
See also#
Python Script#
#!/usr/bin/env python
# coding: utf-8
# ## Convert AMS text input to Python code that builds an input model
#
# Input models are the recommended way to define AMS input from Python. Any AMS text
# input can be turned into an input model with `from_input`, and `to_python` then returns the
# Python code that rebuilds it, as an import block and a body. This is the quickest way to find out how a block or
# key you already know from the text input is spelled in Python.
inp = """
Task GeometryOptimization
GeometryOptimization
MaxIterations 10000
PretendConverged Yes
End
Engine ADF
Basis
Type DZP
End
XC
GGA PBE
End
Solvation
C-Mat Potential
Charged Method=Conjugate-Gradient
SCF Variational
Solv Epsilon=78.4 Radius=1.4 Cav0=1.321 Cav1=0.0067639
Surf Delley
End
EndEngine
"""
from scm.inputs import AMS
imports, body = AMS.from_input(inp).to_python()
print(imports)
print()
print(body)
# ## Convert AMS text input to a Settings object
#
# PLAMS also still accepts its own `Settings` objects. `AMSJob.from_input` parses AMS text
# input into the equivalent `Settings`, which is useful when maintaining older scripts.
#
# A complete run script, as written by AMSinput, can be converted into a ready to run PLAMS
# script with `$AMSBIN/amspython -m scm.utils.convert_run_to_plams myjob.run myjob.py`. That is
# the same conversion that **File → Export PLAMS script...** performs in AMSinput, and it
# writes a script that builds an input model.
from scm.plams import AMSJob
settings = AMSJob.from_input(inp).settings
print(f"{type(settings)=}")
print(settings)