add library interface to Variable::internal_set()
This commit is contained in:
@ -282,6 +282,8 @@ class lammps(object):
|
||||
self.lib.lammps_config_accelerator.argtypes = [c_char_p, c_char_p, c_char_p]
|
||||
|
||||
self.lib.lammps_set_variable.argtypes = [c_void_p, c_char_p, c_char_p]
|
||||
self.lib.lammps_set_string_variable.argtypes = [c_void_p, c_char_p, c_char_p]
|
||||
self.lib.lammps_set_internal_variable.argtypes = [c_void_p, c_char_p, c_double]
|
||||
|
||||
self.lib.lammps_has_style.argtypes = [c_void_p, c_char_p, c_char_p]
|
||||
|
||||
@ -1252,6 +1254,8 @@ class lammps(object):
|
||||
def set_variable(self,name,value):
|
||||
"""Set a new value for a LAMMPS string style variable
|
||||
|
||||
.. deprecated:: TBD
|
||||
|
||||
This is a wrapper around the :cpp:func:`lammps_set_variable`
|
||||
function of the C-library interface.
|
||||
|
||||
@ -1271,6 +1275,52 @@ class lammps(object):
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def set_string_variable(self,name,value):
|
||||
"""Set a new value for a LAMMPS string style variable
|
||||
|
||||
.. versionadded:: TBD
|
||||
|
||||
This is a wrapper around the :cpp:func:`lammps_set_string_variable`
|
||||
function of the C-library interface.
|
||||
|
||||
:param name: name of the variable
|
||||
:type name: string
|
||||
:param value: new variable value
|
||||
:type value: any. will be converted to a string
|
||||
:return: either 0 on success or -1 on failure
|
||||
:rtype: int
|
||||
"""
|
||||
if name: name = name.encode()
|
||||
else: return -1
|
||||
if value: value = str(value).encode()
|
||||
else: return -1
|
||||
with ExceptionCheck(self):
|
||||
return self.lib.lammps_set_string_variable(self.lmp,name,value)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def set_internal_variable(self,name,value):
|
||||
"""Set a new value for a LAMMPS internal style variable
|
||||
|
||||
.. versionadded:: TBD
|
||||
|
||||
This is a wrapper around the :cpp:func:`lammps_set_internal_variable`
|
||||
function of the C-library interface.
|
||||
|
||||
:param name: name of the variable
|
||||
:type name: string
|
||||
:param value: new variable value
|
||||
:type value: float or compatible. will be converted to float
|
||||
:return: either 0 on success or -1 on failure
|
||||
:rtype: int
|
||||
"""
|
||||
if name: name = name.encode()
|
||||
else: return -1
|
||||
with ExceptionCheck(self):
|
||||
return self.lib.lammps_set_internal_variable(self.lmp,name,value)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# return vector of atom properties gathered across procs
|
||||
# 3 variants to match src/library.cpp
|
||||
# name = atom property recognized by LAMMPS in atom->extract()
|
||||
|
||||
Reference in New Issue
Block a user