Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
multiscale
lammps
Commits
93f60330
Commit
93f60330
authored
7 years ago
by
Richard Berger
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation about fix python
parent
110bb79b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/src/Section_python.txt
+2
-1
2 additions, 1 deletion
doc/src/Section_python.txt
doc/src/fix_python.txt
+75
-0
75 additions, 0 deletions
doc/src/fix_python.txt
doc/src/fixes.txt
+1
-0
1 addition, 0 deletions
doc/src/fixes.txt
doc/src/python.txt
+4
-1
4 additions, 1 deletion
doc/src/python.txt
with
82 additions
and
2 deletions
doc/src/Section_python.txt
+
2
−
1
View file @
93f60330
...
@@ -155,7 +155,8 @@ commands.
...
@@ -155,7 +155,8 @@ commands.
See the "python"_python.html doc page and the "variable"_variable.html
See the "python"_python.html doc page and the "variable"_variable.html
doc page for its python-style variables for more info, including
doc page for its python-style variables for more info, including
examples of Python code you can write for both pure Python operations
examples of Python code you can write for both pure Python operations
and callbacks to LAMMPS.
and callbacks to LAMMPS. See "fix python"_fix_python.html to learn about
possibilities to execute Python code during each time step.
To run pure Python code from LAMMPS, you only need to build LAMMPS
To run pure Python code from LAMMPS, you only need to build LAMMPS
with the PYTHON package installed:
with the PYTHON package installed:
...
...
This diff is collapsed.
Click to expand it.
doc/src/fix_python.txt
0 → 100644
+
75
−
0
View file @
93f60330
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Section_commands.html#comm)
:line
fix python command :h3
[Syntax:]
fix ID group-ID python callback function_name :pre
ID, group-ID are ignored by this fix :ulb,l
python = style name of this fix command :l
callback = {post_force} or {end_of_step} :l
{post_force} = callback after force computations on atoms
{end_of_step} = callback after each time step :pre
:ule
[Examples:]
python post_force_callback here """
from lammps import lammps :pre
def post_force_callback(lammps_ptr, vflag):
lmp = lammps(ptr=lammps_ptr)
# access LAMMPS state using Python interface
""" :pre
python end_of_step_callback here """
def end_of_step_callback(lammps_ptr):
lmp = lammps(ptr=lammps_ptr)
# access LAMMPS state using Python interface
""" :pre
fix pf all python post_force post_force_callback
fix eos all python end_of_step end_of_step_callback :pre
[Description:]
This fix allows you to call a Python function during a simulation run.
The callback is either executed after forces have been applied to atoms
or at the end of each time step.
Callback functions must be declared in the global scope of the
active Python interpreter. This can either be done by defining it
inline using the python command or by importing functions from other
Python modules. If LAMMPS is driven using the library interface from
Python, functions defined in the driving Python interpreter can also
be executed.
Each callback is given a pointer object as first argument. This can be
used to initialize an instance of the lammps Python interface, which
gives access to the LAMMPS state from Python.
IMPORTANT NOTE: While you can access the state of LAMMPS via library functions
from these callbacks, trying to execute input script commands will in the best
case not work or in the worst case result in undefined behavior.
[Restrictions:]
This fix is part of the PYTHON package. It is only enabled if
LAMMPS was built with that package. See the "Making
LAMMPS"_Section_start.html#start_3 section for more info.
Building LAMMPS with the PYTHON package will link LAMMPS with the
Python library on your system. Settings to enable this are in the
lib/python/Makefile.lammps file. See the lib/python/README file for
information on those settings.
[Related commands:]
"python command"_python.html
This diff is collapsed.
Click to expand it.
doc/src/fixes.txt
+
1
−
0
View file @
93f60330
...
@@ -111,6 +111,7 @@ Fixes :h1
...
@@ -111,6 +111,7 @@ Fixes :h1
fix_press_berendsen
fix_press_berendsen
fix_print
fix_print
fix_property_atom
fix_property_atom
fix_python
fix_qbmsst
fix_qbmsst
fix_qeq
fix_qeq
fix_qeq_comb
fix_qeq_comb
...
...
This diff is collapsed.
Click to expand it.
doc/src/python.txt
+
4
−
1
View file @
93f60330
...
@@ -405,6 +405,9 @@ or other variables may have hidden side effects as well. In these
...
@@ -405,6 +405,9 @@ or other variables may have hidden side effects as well. In these
cases, LAMMPS has no simple way to check that something illogical is
cases, LAMMPS has no simple way to check that something illogical is
being attempted.
being attempted.
The same applies to Python functions called during a simulation run at
each time step using "fix python"_fix_python.html.
:line
:line
If you run Python code directly on your workstation, either
If you run Python code directly on your workstation, either
...
@@ -490,6 +493,6 @@ different source files, problems may occur.
...
@@ -490,6 +493,6 @@ different source files, problems may occur.
[Related commands:]
[Related commands:]
"shell"_shell.html, "variable"_variable.html
"shell"_shell.html, "variable"_variable.html
, "fix python"_fix_python.html
[Default:] none
[Default:] none
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment