Hi
I am using the lammps python api to compute quantities (energy, forces …) and I run several (let says hundreds) of small lammps run.
Is there a way to prevent stdout to be printed each time lammps is called ?
I use the lammps.lammps()
class.
Thanks
When creating the LAMMPS instance, you can pass “command line flags” to the constructor, if you use -screen none
it should close the stdout file pointer. You can also silence or redirect the log file output with the -log
flag. Check out the examples here: 2.3.4. Creating or deleting a LAMMPS object — LAMMPS documentation
and then study: 2.4. The lammps Python module — LAMMPS documentation
and: 4.2. Command-line options — LAMMPS documentation
Thank you.
I did the following which suppress everything, I then get/extract what I need from python.
import os
import lammps
lmp = lammps.lammps(cmdargs=["-log", "none", "-screen", os.devnull, "-nocite"])
1 Like
Thanks for the confirming a solution.
I am curious, though: what is wrong with using -screen none? Why did you opt for redirecting the output. With -screen none you don’t even have the output written (which is saving time to format and buffer the strings)
You are true, I did not read enough the doc and I missed that the “none” option exists also for the screen command.
lmp = lammps.lammps(cmdargs=["-log", "none", "-screen", "none", "-nocite"])