├── .github
└── workflows
│ ├── main.yml
│ └── pythonpackage.yml
├── .gitignore
├── LICENSE
├── README.md
├── docs
├── Makefile
├── about.rst
├── api_reference
│ └── index.rst
├── conf.py
├── getting_started
│ ├── index.rst
│ └── python
│ │ └── getting_started.py
├── index.rst
├── installation.rst
└── requirements.txt
├── examples
├── logfiles
│ └── crack_log.lammps
└── plot_logdata.py
├── lammps_logfile
├── File.py
├── __init__.py
├── cmd_interface.py
└── utils.py
├── setup.py
└── tests
├── __init__.py
├── data
├── in.crack
└── log.lammps
└── test_File.py
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: build docs
2 | on:
3 | push:
4 | branches:
5 | - master
6 |
7 | jobs:
8 | deploy:
9 | runs-on: ubuntu-22.04
10 | steps:
11 | - uses: actions/checkout@v2
12 |
13 | - name: Setup Python
14 | uses: actions/setup-python@v2
15 | with:
16 | python-version: '3.10'
17 |
18 | - name: Upgrade pip
19 | run: |
20 | # install pip=>20.1 to use "pip cache dir"
21 | python3 -m pip install --upgrade pip
22 | - name: Get pip cache dir
23 | id: pip-cache
24 | run: echo "::set-output name=dir::$(pip cache dir)"
25 |
26 | - name: Cache dependencies
27 | uses: actions/cache@v1
28 | with:
29 | path: ${{ steps.pip-cache.outputs.dir }}
30 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
31 | restore-keys: |
32 | ${{ runner.os }}-pip-
33 | - name: Install dependencies
34 | run: |
35 | python3 -m pip install -r ./docs/requirements.txt
36 | python3 -m pip install .
37 |
38 | - name: Build
39 | run: |
40 | cd docs && make examples && make html
41 |
42 | - name: Deploy
43 | uses: peaceiris/actions-gh-pages@v3
44 | with:
45 | github_token: ${{ secrets.GITHUB_TOKEN }}
46 | force_orphan: true
47 | publish_dir: ./docs/_build/html
48 |
--------------------------------------------------------------------------------
/.github/workflows/pythonpackage.yml:
--------------------------------------------------------------------------------
1 | name: Install and tests
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: ubuntu-latest
9 | strategy:
10 | max-parallel: 4
11 | matrix:
12 | python-version: [3.10.15]
13 |
14 | steps:
15 | - uses: actions/checkout@v1
16 | - name: Set up Python ${{ matrix.python-version }}
17 | uses: actions/setup-python@v1
18 | with:
19 | python-version: ${{ matrix.python-version }}
20 | - name: Install dependencies
21 | run: |
22 | python -m pip install --upgrade pip
23 |
24 | - name: setup
25 | run: |
26 | pip install .
27 | - name: Test with pytest
28 | run: |
29 | pip install pytest
30 | pytest
31 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 | MANIFEST
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 | .pytest_cache/
49 |
50 | # Translations
51 | *.mo
52 | *.pot
53 |
54 | # Django stuff:
55 | *.log
56 | local_settings.py
57 | db.sqlite3
58 |
59 | # Flask stuff:
60 | instance/
61 | .webassets-cache
62 |
63 | # Scrapy stuff:
64 | .scrapy
65 |
66 | # Sphinx documentation
67 | docs/_build/
68 |
69 | # PyBuilder
70 | target/
71 |
72 | # Jupyter Notebook
73 | .ipynb_checkpoints
74 |
75 | # pyenv
76 | .python-version
77 |
78 | # celery beat schedule file
79 | celerybeat-schedule
80 |
81 | # SageMath parsed files
82 | *.sage.py
83 |
84 | # Environments
85 | .env
86 | .venv
87 | env/
88 | venv/
89 | ENV/
90 | env.bak/
91 | venv.bak/
92 |
93 | # Spyder project settings
94 | .spyderproject
95 | .spyproject
96 |
97 | # Rope project settings
98 | .ropeproject
99 |
100 | # mkdocs documentation
101 | /site
102 |
103 | # mypy
104 | .mypy_cache/
105 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | # LAMMPS logfile reader
3 | Tool to read a logfile produced by [LAMMPS](https://lammps.sandia.gov) into a simple python data structure with a `get()`-function providing the log data.
4 |
5 | ## Installation
6 | From pypi (preferred/stable)
7 | ```
8 | pip install lammps-logfile
9 | ```
10 | Depending on your python installation, you may have to use `pip3` instead of `pip`. This is usualy the case if you need to run `python3` rather than `python` to run python version 3.
11 |
12 | Install using pip directly from github to get the latest (possibly unstable) version:
13 | ```
14 | pip install git+https://github.com/henriasv/lammps-logfile.git
15 | ```
16 | Or by cloning the repository:
17 | ```
18 | git clone https://github.com/henriasv/lammps-logfile.git
19 | cd lammps-logfile
20 | pip3 install .
21 | ```
22 |
23 | ## Basic usage
24 |
25 | ```
26 | import lammps_logfile
27 |
28 | log = lammps_logfile.File("path/to/logfile")
29 |
30 | x = log.get("Time")
31 | y = log.get("Temp")
32 |
33 | import matplotlib.pyplot as plt
34 | plt.plot(x, y)
35 | plt.show()
36 | ```
37 | This will give the concatenated log entries of all the runs where the style of the thermo output didn't change with respect to the last run. I.e. if the entries in the `thermo_style` was not changed between runs it will contain the log data for all the timesteps. If the `thermo_style` *was* changed, `x` and `y` will contain the data from all the timesteps after the `thermo_style` was changed for the last time.
38 |
39 | ## Multiple runs in the same log file
40 | If multiple run statements have been made in a simulation, these can be retrieved bu supplying the `run_num` keyword to the `get()`-function
41 |
42 | ```
43 | import lammps_logfile
44 |
45 | log = lammps_logfile.File("path/to/logfile")
46 |
47 | x = log.get("Time", run_num=N)
48 | y = log.get("Temp", run_num=N)
49 |
50 | import matplotlib.pyplot as plt
51 | plt.plot(x, y)
52 | plt.show()
53 | ```
54 | In this case, `x` and `y` will contain the log data from the `N`'th `run` command in LAMMPS, counting from 0.
55 |
56 | Any invalid call to the `get()`-function will result in the function returning `None`. This happes if the user asks for a thermo propery that does not exist in the log file, or if the user asks for a `run_num` larger than the number of runs in the logfile.
57 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?=
7 | SPHINXBUILD ?= sphinx-build
8 | SOURCEDIR = .
9 | BUILDDIR = _build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | .PHONY: examples
18 | examples:
19 | cd getting_started/python && python3 getting_started.py > output.txt && cd ../..
20 | # Catch-all target: route all unknown targets to Sphinx using the new
21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
22 | %: Makefile
23 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24 |
25 |
--------------------------------------------------------------------------------
/docs/about.rst:
--------------------------------------------------------------------------------
1 | About lammps-logfile
2 | ========================
3 | :code:`lammps-logfile` is a lightweight package for reading time-series data from LAMMPS log files.
4 |
5 | Basic usage to get and plot the temperature in a simulation as a function of time is:
6 |
7 | .. code-block:: python
8 |
9 | import lammps_logfile
10 |
11 | log = lammps_logfile.File("log.lammps")
12 |
13 | x = log.get("Time")
14 | y = log.get("Temp")
15 |
16 | import matplotlib.pyplot as plt
17 | plt.plot(x, y)
18 | plt.show()
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/api_reference/index.rst:
--------------------------------------------------------------------------------
1 | API Reference
2 | =========================
3 |
4 | File
5 | --------------------------
6 | .. automodule:: lammps_logfile.File
7 | :members:
8 |
9 |
10 | Utilities
11 | --------------------------
12 | .. automodule:: lammps_logfile.utils
13 | :members:
14 |
15 | Command line interface
16 | --------------------------
17 | .. argparse::
18 | :ref: lammps_logfile.cmd_interface.get_parser
19 | :prog: lammps_logplotter
20 |
21 | Indices and tables
22 | ------------------------
23 |
24 | * :ref:`genindex`
25 | * :ref:`modindex`
26 | * :ref:`search`
--------------------------------------------------------------------------------
/docs/conf.py:
--------------------------------------------------------------------------------
1 | # Configuration file for the Sphinx documentation builder.
2 | #
3 | # This file only contains a selection of the most common options. For a full
4 | # list see the documentation:
5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html
6 |
7 | # -- Path setup --------------------------------------------------------------
8 |
9 | # If extensions (or modules to document with autodoc) are in another directory,
10 | # add these directories to sys.path here. If the directory is relative to the
11 | # documentation root, use os.path.abspath to make it absolute, like shown here.
12 | #
13 | import sphinx_rtd_theme
14 | import os
15 | import sys
16 | sys.path.insert(0, os.path.abspath('..'))
17 |
18 |
19 | # -- Project information -----------------------------------------------------
20 |
21 | project = 'lammps-logfile'
22 | copyright = '2020, Henrik Andersen Sveinsson'
23 | author = 'Henrik Andersen Sveinsson'
24 |
25 |
26 | # -- General configuration ---------------------------------------------------
27 |
28 | # Add any Sphinx extension module names here, as strings. They can be
29 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30 | # ones.
31 | extensions = [ "sphinx.ext.autodoc",
32 | "sphinx.ext.doctest",
33 | "recommonmark",
34 | "sphinxarg.ext"]
35 | add_module_names = False
36 |
37 | # Add any paths that contain templates here, relative to this directory.
38 | templates_path = ['_templates']
39 |
40 | # List of patterns, relative to source directory, that match files and
41 | # directories to ignore when looking for source files.
42 | # This pattern also affects html_static_path and html_extra_path.
43 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
44 |
45 |
46 | # -- Options for HTML output -------------------------------------------------
47 |
48 | # The theme to use for HTML and HTML Help pages. See the documentation for
49 | # a list of builtin themes.
50 | #
51 | html_theme = 'sphinx_rtd_theme'
52 |
53 | # Add any paths that contain custom static files (such as style sheets) here,
54 | # relative to this directory. They are copied after the builtin static files,
55 | # so a file named "default.css" will overwrite the builtin "default.css".
56 | #html_static_path = ['_static']
--------------------------------------------------------------------------------
/docs/getting_started/index.rst:
--------------------------------------------------------------------------------
1 | Getting started
2 | ==================
3 |
4 | Getting log data
5 | -----------------
6 |
7 | .. literalinclude:: python/getting_started.py
8 | :lines: 1-6
9 |
10 | Now the arrays :code:`t` and :code:`temp` contain the log data corresponding to the :code:`Time` and :code:`Temp` columns in the log file.
11 |
12 | Plotting log data
13 | -----------------
14 |
15 | .. literalinclude:: python/getting_started.py
16 | :lines: 8-14
17 |
18 | To make the plot pop up in a window rather than being saved to a file, run `plt.show()` rather than `plt.savefig(...)`.
19 |
20 | .. figure:: python/time_temp.png
21 | :scale: 100 %
22 | :alt: Plot of temperature vs. time
23 |
24 | Plot of temperature vs. time
25 |
26 |
27 | Running average
28 | ----------------
29 | .. literalinclude:: python/getting_started.py
30 | :lines: 16-24
31 |
32 | .. figure:: python/time_temp_avg.png
33 | :scale: 100 %
34 | :alt: Plot of temperature vs. time
35 |
36 | Plot of temperature vs. time. The blue curve is the raw output, whereas in the orange curve the temperature has been smoothed over a 100 log entries wide averaging window.
37 |
38 | What data are available in the log file?
39 | ----------------------------------------
40 | To inspect what columns are available, you can run the `get_keywords`-method on the `File` object:
41 |
42 | .. code-block:: python
43 |
44 | print(log.get_keywords())
45 |
46 | This command yields an output like the one below, which shows what columns we may :code:`get` from the :code:`File` object:
47 |
48 | .. literalinclude:: python/output.txt
49 |
50 | Command line tool
51 | ------------------
52 | The following is the help message from the command line tool `lammps_logplotter` that comes with lammps-logplotter. This tool is meant to quicky inspect lammps log files without having to write a python script.
53 |
54 | .. code-block:: bash
55 |
56 | usage: lammps_logplotter [-h] [-x X] [-y Y [Y ...]] [-a RUNNING_AVERAGE] input_file
57 |
58 | Plot contents from lammps log files
59 |
60 | positional arguments:
61 | input_file Lammps log file containing thermo output from lammps simulation.
62 |
63 | optional arguments:
64 | -h, --help show this help message and exit
65 | -x X Data to plot on the first axis
66 | -y Y [Y ...] Data to plot on the second axis. You can supply several names to get several plot lines in the same figure.
67 | -a RUNNING_AVERAGE, --running_average RUNNING_AVERAGE
68 | Optionally average over this many log entries with a running average. Some thermo properties fluctuate wildly, and often we are interested in te
69 | running average of properties like temperature and pressure.
--------------------------------------------------------------------------------
/docs/getting_started/python/getting_started.py:
--------------------------------------------------------------------------------
1 | from lammps_logfile import File
2 |
3 | log = File("../../../examples/logfiles/crack_log.lammps")
4 |
5 | t = log.get("Time")
6 | temp = log.get("Temp")
7 |
8 | import matplotlib.pyplot as plt
9 |
10 | plt.plot(t, temp)
11 | plt.xlabel("Time (ps)")
12 | plt.ylabel("Temperature (K)")
13 | plt.ylim([215, 225])
14 | plt.savefig("time_temp.png")
15 |
16 | from lammps_logfile import running_mean
17 |
18 | temp_avg = running_mean(temp, 100)
19 |
20 | plt.plot(t, temp_avg)
21 | plt.xlabel("Time (ps)")
22 | plt.ylabel("Temperature (K)")
23 | plt.ylim([215, 225])
24 | plt.savefig("time_temp_avg.png")
25 |
26 | print(log.get_keywords())
27 |
28 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | Welcome to lammps-logfile's documentation
2 | =========================================
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | about
8 | installation
9 | getting_started/index
10 | api_reference/index
--------------------------------------------------------------------------------
/docs/installation.rst:
--------------------------------------------------------------------------------
1 | Installation
2 | ======================
3 |
4 | Install using pip
5 |
6 | .. code-block:: bash
7 |
8 | pip install lammps-logfile
9 |
10 | or manually
11 |
12 | .. code-block:: bash
13 |
14 | git clone https://github.com/henriasv/lammps-logfile
15 | cd lammps-logfile
16 | python setup.py
17 |
18 |
--------------------------------------------------------------------------------
/docs/requirements.txt:
--------------------------------------------------------------------------------
1 | sphinx
2 | sphinx_rtd_theme
3 | recommonmark
4 | sphinx.argparse
--------------------------------------------------------------------------------
/examples/plot_logdata.py:
--------------------------------------------------------------------------------
1 | import os
2 | import matplotlib.pyplot as plt
3 |
4 | import lammps_logfile
5 |
6 | log = lammps_logfile.File(os.path.join(os.path.dirname(__file__), "logfiles", "crack_log.lammps"))
7 |
8 | print("Log keywords: ", log.get_keywords())
9 |
10 | x = log.get("Time")
11 | y = log.get("Pyy")
12 |
13 | plt.figure(figsize=(6,6))
14 | plt.subplot(221)
15 | plt.plot(x, y)
16 | plt.xlabel("$t$")
17 | plt.ylabel("$p_{yy}$")
18 |
19 | plt.subplot(222)
20 | for i in range(log.get_num_partial_logs()):
21 | x = log.get("Time", run_num=i)
22 | y = log.get("Pyy", run_num=i)
23 | plt.plot(x, y)
24 | plt.xlabel("$t$")
25 | plt.ylabel("$p_{yy}$")
26 |
27 | plt.subplot(223)
28 | x = log.get("Time")
29 | y = log.get("Temp")
30 | plt.plot(x, y)
31 | plt.xlabel("$t$")
32 | plt.ylabel("$T$")
33 |
34 | plt.subplot(224)
35 | for i in range(log.get_num_partial_logs()):
36 | x = log.get("Time", run_num=i)
37 | y = log.get("Temp", run_num=i)
38 | plt.plot(x, y)
39 | plt.xlabel("$t$")
40 | plt.ylabel("$T$")
41 | plt.tight_layout()
42 | plt.show()
43 |
44 |
--------------------------------------------------------------------------------
/lammps_logfile/File.py:
--------------------------------------------------------------------------------
1 | from io import BytesIO, StringIO
2 |
3 | import numpy as np
4 | import pandas as pd
5 |
6 |
7 | class File:
8 | """Class for handling lammps log files.
9 |
10 | Parameters
11 | ----------------------
12 | :param ifile: path to lammps log file
13 | :type ifile: string or file
14 |
15 | """
16 | def __init__(self, ifile):
17 | # Identifiers for places in the log file
18 | self.start_thermo_strings = ["Memory usage per processor", "Per MPI rank memory allocation"]
19 | self.stop_thermo_strings = ["Loop time", "ERROR", "Fix halt condition"]
20 | self.data_dict = {}
21 | self.keywords = []
22 | self.output_before_first_run = ""
23 | self.partial_logs = []
24 | if hasattr(ifile, "read"):
25 | self.logfile = ifile
26 | else:
27 | self.logfile = open(ifile, 'r')
28 | self.read_file_to_dict()
29 |
30 | def read_file_to_dict(self):
31 | contents = self.logfile.readlines()
32 | keyword_flag = False
33 | before_first_run_flag = True
34 | i = 0
35 | while i < len(contents):
36 | line = contents[i]
37 | if before_first_run_flag:
38 | self.output_before_first_run += line
39 |
40 | if keyword_flag:
41 | keywords = line.split()
42 | tmpString = ""
43 | # Check wheter any of the thermo stop strings are in the present line
44 | while not sum([string in line for string in self.stop_thermo_strings]) >= 1:
45 | if "\n" in line:
46 | tmpString+=line
47 | i+=1
48 | if i= 1:
68 | keyword_flag = True
69 | before_first_run_flag = False
70 | i += 1
71 |
72 | def flush_dict_and_set_new_keyword(self, keywords):
73 | self.data_dict = {}
74 | for entry in keywords:
75 | self.data_dict[entry] = np.asarray([])
76 | self.keywords = keywords
77 |
78 | def get(self, entry_name, run_num=-1):
79 | """Get time-series from log file by name.
80 |
81 | Paramerers
82 | --------------------
83 | :param entry_name: Name of the entry, for example "Temp"
84 | :type entry_name: str
85 | :param run_num: Lammps simulations commonly involve several run-commands. Here you may choose what run you want the log data from. Default of :code:`-1` returns data from all runs concatenated
86 | :type run_num: int
87 |
88 | If the rows in the log file changes between runs, the logs are being flushed.
89 | """
90 |
91 | if run_num == -1:
92 | if entry_name in self.data_dict.keys():
93 | return self.data_dict[entry_name]
94 | else:
95 | return None
96 | else:
97 | if len(self.partial_logs) > run_num:
98 | partial_log = self.partial_logs[run_num]
99 | if entry_name in partial_log.keys():
100 | return partial_log[entry_name]
101 | else:
102 | return None
103 | else:
104 | return None
105 |
106 | def get_keywords(self, run_num=-1):
107 | """Return list of available data columns in the log file."""
108 | if run_num == -1:
109 | return sorted(self.keywords)
110 | else:
111 | if len(self.partial_logs) > run_num:
112 | return sorted(list(self.partial_logs[run_num].keys()))
113 | else:
114 | return None
115 |
116 | def to_exdir_group(self, name, exdirfile):
117 | group = exdirfile.require_group(name)
118 | for i, log in enumerate(self.partial_logs):
119 | subgroup = group.require_group(str(i))
120 | for key, value in log.items():
121 | key = key.replace("/", ".")
122 | subgroup.create_dataset(key, data=value)
123 |
124 | def to_dataframe(self, run_num=-1):
125 | return pd.DataFrame(self.partial_logs[run_num])
126 |
127 |
128 | def get_num_partial_logs(self):
129 | return len(self.partial_logs)
130 |
131 | @property
132 | def names(self):
133 | """Exposes the keywords returned by get_keywords."""
134 | return self.get_keywords()
135 |
--------------------------------------------------------------------------------
/lammps_logfile/__init__.py:
--------------------------------------------------------------------------------
1 | from .File import File
2 | from .utils import running_mean, get_color_value, get_matlab_color
3 | from .cmd_interface import run
--------------------------------------------------------------------------------
/lammps_logfile/cmd_interface.py:
--------------------------------------------------------------------------------
1 | from lammps_logfile import File
2 | from lammps_logfile import running_mean
3 | import argparse
4 | import matplotlib.pyplot as plt
5 |
6 | def get_parser():
7 | parser = argparse.ArgumentParser(description="Plot contents from lammps log files. Input file argument comes before keyword arguments. ")
8 | parser.add_argument("-x", type=str, default="Time", help="Data to plot on the first axis")
9 | parser.add_argument("-y", type=str, nargs="+", help="Data to plot on the second axis. You can supply several names to get several plot lines in the same figure.")
10 | parser.add_argument("-a", "--running_average", type=int, default=1, help="Optionally average over this many log entries with a running average. Some thermo properties fluctuate wildly, and often we are interested in te running average of properties like temperature and pressure.")
11 | parser.add_argument("input_file", metavar='INPUT_FILE', type=str, help="Lammps log file containing thermo output from lammps simulation.")
12 | parser.add_argument("-o", type=str, dest='fout', default='', help='Save the figure to this file; the format must be supported by matplotlib.')
13 | parser.add_argument("-c", "--columns", action='store_true', default=False, help='Print columns of the lammps logfile')
14 |
15 | return parser
16 |
17 | def run():
18 | args = get_parser().parse_args()
19 | log = File(args.input_file)
20 |
21 | if args.columns:
22 | print(f"Columns available in log file:\n{' '.join(log.get_keywords())}")
23 | if args.y is None:
24 | exit(0)
25 |
26 | x = log.get(args.x)
27 | if args.running_average >= 2:
28 | x = running_mean(x, args.running_average)
29 | for y in args.y:
30 | data = log.get(y)
31 | if args.running_average >= 2:
32 | data = running_mean(data, args.running_average)
33 |
34 | plt.plot(x, data, label=y)
35 | plt.legend()
36 | plt.show()
37 | if args.fout != '':
38 | plt.savefig(args.fout, dpi=300)
39 |
40 |
--------------------------------------------------------------------------------
/lammps_logfile/utils.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import matplotlib
3 |
4 | def running_mean(data, N):
5 | """Calculate running mean of an array-like dataset.
6 |
7 | Parameters
8 | --------------------
9 | :param data: The array
10 | :type data: 1d array-like
11 | :param N: Width of the averaging window
12 | :type N: int
13 |
14 | """
15 |
16 | data = np.asarray(data)
17 | if N == 1:
18 | return data
19 | else:
20 | retArray = np.zeros(data.size)*np.nan
21 | padL = int(N/2)
22 | padR = N-padL-1
23 | retArray[padL:-padR] = np.convolve(data, np.ones((N,))/N, mode='valid')
24 | return retArray
25 |
26 | def get_color_value(value, minValue, maxValue, cmap='viridis'):
27 | """Get color from colormap.
28 |
29 | Parameters
30 | -----------------
31 | :param value: Value used tpo get color from colormap
32 | :param minValue: Minimum value in colormap. Values below this value will saturate on the lower color of the colormap.
33 | :param maxValue: Maximum value in colormap. Values above this value will saturate on the upper color of the colormap.
34 |
35 | :returns: 4-vector containing colormap values.
36 |
37 | This is useful if you are plotting data from several simulations, and want to color them based on some parameters changing between the simulations. For example, you may want the color to gradually change along a clormap as the temperature increases.
38 |
39 | """
40 | diff = maxValue-minValue
41 | cmap = matplotlib.cm.get_cmap(cmap)
42 | rgba = cmap((value-minValue)/diff)
43 | return rgba
44 |
45 | def get_matlab_color(i):
46 | """Get colors from matlabs standard color order.
47 |
48 | Parameters
49 | -------------
50 | :param i: Index. Cycles with a period of 7, so calling with 1 returns the same color as calling with 8.
51 | :type i: int
52 |
53 | :returns: color as 3-vector
54 |
55 | """
56 | colors = np.asarray([ [0, 0.447000000000000, 0.741000000000000],
57 | [0.850000000000000, 0.325000000000000, 0.098000000000000],
58 | [0.929000000000000, 0.694000000000000, 0.125000000000000],
59 | [0.494000000000000, 0.184000000000000, 0.556000000000000],
60 | [0.466000000000000, 0.674000000000000, 0.188000000000000],
61 | [0.301000000000000, 0.745000000000000, 0.933000000000000],
62 | [0.635000000000000, 0.078000000000000, 0.184000000000000]])
63 | return colors[ i%len(colors) ]
64 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | import setuptools
2 | from setuptools import setup
3 |
4 | with open("README.md", "r") as fh:
5 | long_description = fh.read()
6 |
7 | setup(name='lammps-logfile',
8 | version='1.0.2',
9 | description='Tool to read lammps log files into python data structure',
10 | long_description=long_description,
11 | long_description_content_type="text/markdown",
12 | url='http://github.com/henriasv/lammps-logfile',
13 | author='Henrik Andersen Sveinsson',
14 | author_email='henrik.sveinsson@me.com',
15 | license='GNU GPL v3.0',
16 | packages=setuptools.find_packages(),
17 | test_suite='nose.collector',
18 | tests_require=['nose'],
19 | install_requires=['pandas', 'numpy', 'matplotlib'],
20 | entry_points={
21 | 'console_scripts': [
22 | 'lammps_logplotter=lammps_logfile.cmd_interface:run'
23 | ]
24 | },
25 | zip_safe=False)
26 |
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/henriasv/lammps-logfile/d31b1fb0ae9896507c00877dfca48b05bfdc534e/tests/__init__.py
--------------------------------------------------------------------------------
/tests/data/in.crack:
--------------------------------------------------------------------------------
1 | # 2d LJ crack simulation
2 |
3 | dimension 2
4 | boundary s s p
5 |
6 | atom_style atomic
7 | neighbor 0.3 bin
8 | neigh_modify delay 5
9 |
10 | # create geometry
11 |
12 | lattice hex 0.93
13 | region box block 0 100 0 40 -0.25 0.25
14 | create_box 5 box
15 | create_atoms 1 box
16 |
17 | mass 1 1.0
18 | mass 2 1.0
19 | mass 3 1.0
20 | mass 4 1.0
21 | mass 5 1.0
22 |
23 | # LJ potentials
24 |
25 | pair_style lj/cut 2.5
26 | pair_coeff * * 1.0 1.0 2.5
27 |
28 | # define groups
29 |
30 | region 1 block INF INF INF 1.25 INF INF
31 | group lower region 1
32 | region 2 block INF INF 38.75 INF INF INF
33 | group upper region 2
34 | group boundary union lower upper
35 | group mobile subtract all boundary
36 |
37 | region leftupper block INF 20 20 INF INF INF
38 | region leftlower block INF 20 INF 20 INF INF
39 | group leftupper region leftupper
40 | group leftlower region leftlower
41 |
42 | set group leftupper type 2
43 | set group leftlower type 3
44 | set group lower type 4
45 | set group upper type 5
46 |
47 | # initial velocities
48 |
49 | compute new mobile temp
50 | velocity mobile create 0.01 887723 temp new
51 | velocity upper set 0.0 0.3 0.0
52 | velocity mobile ramp vy 0.0 0.3 y 1.25 38.75 sum yes
53 |
54 | # fixes
55 |
56 | fix 1 all nve
57 | fix 2 boundary setforce NULL 0.0 0.0
58 |
59 | # run
60 |
61 | timestep 0.003
62 | thermo 100
63 | thermo_style custom step time temp pxx pyy cpuremain
64 |
65 | neigh_modify exclude type 2 3
66 |
67 | run 5000
68 |
69 | thermo_style custom step time temp pxx pyy press cpuremain
70 |
71 | run 5000
72 |
73 | thermo_style custom step temp pxx pyy cpuremain
74 |
75 | run 400
--------------------------------------------------------------------------------
/tests/data/log.lammps:
--------------------------------------------------------------------------------
1 | LAMMPS (22 Jun 2018)
2 | OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (../comm.cpp:87)
3 | using 1 OpenMP thread(s) per MPI task
4 | # 2d LJ crack simulation
5 |
6 | dimension 2
7 | boundary s s p
8 |
9 | atom_style atomic
10 | neighbor 0.3 bin
11 | neigh_modify delay 5
12 |
13 | # create geometry
14 |
15 | lattice hex 0.93
16 | Lattice spacing in x,y,z = 1.11428 1.92998 1.11428
17 | region box block 0 100 0 40 -0.25 0.25
18 | create_box 5 box
19 | Created orthogonal box = (0 0 -0.278569) to (111.428 77.1994 0.278569)
20 | 1 by 1 by 1 MPI processor grid
21 | create_atoms 1 box
22 | Created 8141 atoms
23 | Time spent = 0.00101018 secs
24 |
25 | mass 1 1.0
26 | mass 2 1.0
27 | mass 3 1.0
28 | mass 4 1.0
29 | mass 5 1.0
30 |
31 | # LJ potentials
32 |
33 | pair_style lj/cut 2.5
34 | pair_coeff * * 1.0 1.0 2.5
35 |
36 | # define groups
37 |
38 | region 1 block INF INF INF 1.25 INF INF
39 | group lower region 1
40 | 302 atoms in group lower
41 | region 2 block INF INF 38.75 INF INF INF
42 | group upper region 2
43 | 302 atoms in group upper
44 | group boundary union lower upper
45 | 604 atoms in group boundary
46 | group mobile subtract all boundary
47 | 7537 atoms in group mobile
48 |
49 | region leftupper block INF 20 20 INF INF INF
50 | region leftlower block INF 20 INF 20 INF INF
51 | group leftupper region leftupper
52 | 841 atoms in group leftupper
53 | group leftlower region leftlower
54 | 841 atoms in group leftlower
55 |
56 | set group leftupper type 2
57 | 841 settings made for type
58 | set group leftlower type 3
59 | 841 settings made for type
60 | set group lower type 4
61 | 302 settings made for type
62 | set group upper type 5
63 | 302 settings made for type
64 |
65 | # initial velocities
66 |
67 | compute new mobile temp
68 | velocity mobile create 0.01 887723 temp new
69 | velocity upper set 0.0 0.3 0.0
70 | velocity mobile ramp vy 0.0 0.3 y 1.25 38.75 sum yes
71 |
72 | # fixes
73 |
74 | fix 1 all nve
75 | fix 2 boundary setforce NULL 0.0 0.0
76 |
77 | # run
78 |
79 | timestep 0.003
80 | thermo 100
81 | thermo_style custom step time temp pxx pyy cpuremain
82 |
83 | neigh_modify exclude type 2 3
84 |
85 | run 5000
86 | Neighbor list info ...
87 | update every 1 steps, delay 5 steps, check yes
88 | max neighbors/atom: 2000, page size: 100000
89 | master list distance cutoff = 2.8
90 | ghost atom cutoff = 2.8
91 | binsize = 1.4, bins = 80 56 1
92 | 1 neighbor lists, perpetual/occasional/extra = 1 0 0
93 | (1) pair lj/cut, perpetual
94 | attributes: half, newton on
95 | pair build: half/bin/atomonly/newton
96 | stencil: half/bin/2d/newton
97 | bin: standard
98 | Per MPI rank memory allocation (min/avg/max) = 3.112 | 3.112 | 3.112 Mbytes
99 | Step Time Temp Pxx Pyy CPULeft
100 | 0 0 0.066999022 -0.08406601 0.023352245 0
101 | 100 0.3 0.062586901 -0.11310916 -0.12882594 4.0526512
102 | 200 0.6 0.061882589 -0.15947586 -0.29123755 3.9601936
103 | 300 0.9 0.062212437 -0.20547907 -0.45464633 3.8933103
104 | 400 1.2 0.062324688 -0.24426358 -0.60503271 3.8236127
105 | 500 1.5 0.062352633 -0.27815189 -0.74875218 3.7779129
106 | 600 1.8 0.062615145 -0.31014555 -0.88379594 3.6933088
107 | 700 2.1 0.06288345 -0.33133642 -1.0125663 3.6005621
108 | 800 2.4 0.06341206 -0.35037809 -1.1344373 3.52275
109 | 900 2.7 0.063615289 -0.36733706 -1.2505378 3.4798663
110 | 1000 3 0.064084368 -0.37838922 -1.3583945 3.4124527
111 | 1100 3.3 0.064762835 -0.38621191 -1.4615187 3.3192973
112 | 1200 3.6 0.065321008 -0.39091417 -1.5578001 3.2478472
113 | 1300 3.9 0.066159989 -0.3939606 -1.6518818 3.3870026
114 | 1400 4.2 0.066915292 -0.39096277 -1.7364292 3.486163
115 | 1500 4.5 0.067935205 -0.38911792 -1.8224931 3.3925409
116 | 1600 4.8 0.068950603 -0.38173567 -1.8978622 3.3557195
117 | 1700 5.1 0.069647678 -0.36882884 -1.9719961 3.3213802
118 | 1800 5.4 0.070589688 -0.35355604 -2.038963 3.2253121
119 | 1900 5.7 0.071376824 -0.33506745 -2.1008265 3.1103899
120 | 2000 6 0.072218214 -0.31363701 -2.1606285 2.9923156
121 | 2100 6.3 0.073139872 -0.29218486 -2.2124962 2.8702529
122 | 2200 6.6 0.074092142 -0.26797305 -2.2605065 2.7532846
123 | 2300 6.9 0.075078297 -0.24243601 -2.3024656 2.640411
124 | 2400 7.2 0.076021461 -0.21236784 -2.3419383 2.5274417
125 | 2500 7.5 0.07677898 -0.17776117 -2.3745273 2.4174831
126 | 2600 7.8 0.077802484 -0.1431674 -2.4033595 2.312941
127 | 2700 8.1 0.078773028 -0.10947863 -2.4268424 2.2132354
128 | 2800 8.4 0.0795636 -0.075949648 -2.4439372 2.1139918
129 | 2900 8.7 0.08053241 -0.040620709 -2.4583448 2.0170037
130 | 3000 9 0.081509075 -0.0066445715 -2.4693983 1.9186533
131 | 3100 9.3 0.082590961 0.026296862 -2.4745466 1.8241662
132 | 3200 9.6 0.083747868 0.058053159 -2.4750398 1.7243286
133 | 3300 9.9 0.084896121 0.089586381 -2.4800392 1.6260691
134 | 3400 10.2 0.085918049 0.1227962 -2.4785809 1.5281092
135 | 3500 10.5 0.08669673 0.15909307 -2.4774432 1.4290658
136 | 3600 10.8 0.087672157 0.19877206 -2.4736765 1.3308412
137 | 3700 11.1 0.088566473 0.23131529 -2.4672682 1.2317458
138 | 3800 11.4 0.089161561 0.26596102 -2.4542366 1.1360173
139 | 3900 11.7 0.089763483 0.29277009 -2.4428439 1.0402159
140 | 4000 12 0.08985281 0.31122192 -2.4251574 0.94414878
141 | 4100 12.3 0.088138682 0.32632891 -2.406837 0.84869343
142 | 4200 12.6 0.086254998 0.33387816 -2.3979692 0.75338155
143 | 4300 12.9 0.085723564 0.34342733 -2.3952074 0.65787515
144 | 4400 13.2 0.086494787 0.34461302 -2.3906185 0.56331614
145 | 4500 13.5 0.08682319 0.33886131 -2.3786501 0.46870711
146 | 4600 13.8 0.087008602 0.32460744 -2.3547476 0.37420783
147 | 4700 14.1 0.087520366 0.29442151 -2.3239268 0.28058808
148 | 4800 14.4 0.088731576 0.25391148 -2.2960552 0.18685521
149 | 4900 14.7 0.089962836 0.21900237 -2.2574458 0.093313777
150 | 5000 15 0.090608908 0.18841703 -2.2179781 0
151 | Loop time of 4.65965 on 1 procs for 5000 steps with 8141 atoms
152 |
153 | Performance: 278132.601 tau/day, 1073.042 timesteps/s
154 | 97.5% CPU use with 1 MPI tasks x 1 OpenMP threads
155 |
156 | MPI task timing breakdown:
157 | Section | min time | avg time | max time |%varavg| %total
158 | ---------------------------------------------------------------
159 | Pair | 3.9478 | 3.9478 | 3.9478 | 0.0 | 84.72
160 | Neigh | 0.19429 | 0.19429 | 0.19429 | 0.0 | 4.17
161 | Comm | 0.0036759 | 0.0036759 | 0.0036759 | 0.0 | 0.08
162 | Output | 0.0041168 | 0.0041168 | 0.0041168 | 0.0 | 0.09
163 | Modify | 0.38046 | 0.38046 | 0.38046 | 0.0 | 8.16
164 | Other | | 0.1293 | | | 2.77
165 |
166 | Nlocal: 8141 ave 8141 max 8141 min
167 | Histogram: 1 0 0 0 0 0 0 0 0 0
168 | Nghost: 0 ave 0 max 0 min
169 | Histogram: 1 0 0 0 0 0 0 0 0 0
170 | Neighs: 71389 ave 71389 max 71389 min
171 | Histogram: 1 0 0 0 0 0 0 0 0 0
172 |
173 | Total # of neighbors = 71389
174 | Ave neighs/atom = 8.76907
175 | Neighbor list builds = 100
176 | Dangerous builds = 0
177 |
178 | thermo_style custom step time temp pxx pyy press cpuremain
179 |
180 | run 5000
181 | Per MPI rank memory allocation (min/avg/max) = 3.114 | 3.114 | 3.114 Mbytes
182 | Step Time Temp Pxx Pyy Press CPULeft
183 | 5000 15 0.090608908 0.18837991 -2.2175412 -1.0145806 0
184 | 5100 15.3 0.091245887 0.14407923 -2.1711508 -1.0135358 4.4449849
185 | 5200 15.6 0.091839804 0.091121561 -2.0998723 -1.0043754 4.3448181
186 | 5300 15.9 0.094453238 0.014115988 -2.021764 -1.003824 4.2634337
187 | 5400 16.2 0.096707467 -0.090196664 -1.9160294 -1.003113 4.1779729
188 | 5500 16.5 0.10033942 -0.21809813 -1.7938504 -1.0059743 4.1051702
189 | 5600 16.8 0.10621254 -0.3489582 -1.6504528 -0.99970551 4.0361934
190 | 5700 17.1 0.11294739 -0.46604782 -1.4626835 -0.96436566 3.9937672
191 | 5800 17.4 0.11606476 -0.52859387 -1.2515736 -0.89008373 3.9104784
192 | 5900 17.7 0.12036583 -0.54743406 -1.067752 -0.80759303 3.8190275
193 | 6000 18 0.12319937 -0.52864435 -0.91180314 -0.72022375 3.7308521
194 | 6100 18.3 0.12750402 -0.48741571 -0.7664699 -0.6269428 3.6385232
195 | 6200 18.6 0.13138215 -0.40723012 -0.6355442 -0.52138716 3.5447954
196 | 6300 18.9 0.13547924 -0.33527477 -0.54607801 -0.44067639 3.4510812
197 | 6400 19.2 0.13787406 -0.28779527 -0.47130925 -0.37955226 3.360955
198 | 6500 19.5 0.14098059 -0.23394595 -0.44459574 -0.33927084 3.2724419
199 | 6600 19.8 0.14427435 -0.2046593 -0.44273376 -0.32369653 3.1779037
200 | 6700 20.1 0.14402616 -0.15224598 -0.40945993 -0.28085295 3.100527
201 | 6800 20.4 0.14650767 -0.13052827 -0.41706736 -0.27379781 3.0109762
202 | 6900 20.7 0.15169782 -0.12366203 -0.41010956 -0.26688579 2.9211366
203 | 7000 21 0.15378158 -0.07576874 -0.40276577 -0.23926725 2.8384817
204 | 7100 21.3 0.15648546 -0.042006532 -0.39284705 -0.21742679 2.7480278
205 | 7200 21.6 0.1586544 -0.015158462 -0.39615573 -0.2056571 2.6563434
206 | 7300 21.9 0.16021716 0.02084344 -0.40989747 -0.19452701 2.5576256
207 | 7400 22.2 0.16305481 0.027777436 -0.45547888 -0.21385072 2.4610896
208 | 7500 22.5 0.16284144 0.079005006 -0.47705735 -0.19902617 2.364706
209 | 7600 22.8 0.16426335 0.07728209 -0.47217063 -0.19744427 2.2714654
210 | 7700 23.1 0.16554325 0.070668071 -0.45276681 -0.19104937 2.1746407
211 | 7800 23.4 0.16829508 0.056401348 -0.42215026 -0.18287445 2.0809541
212 | 7900 23.7 0.17000245 0.082559769 -0.37151525 -0.14447774 1.9876522
213 | 8000 24 0.17149488 0.10974507 -0.35277134 -0.12151313 1.8950588
214 | 8100 24.3 0.17313528 0.10325942 -0.31901721 -0.1078789 1.8009028
215 | 8200 24.6 0.17267217 0.1318115 -0.2919738 -0.080081147 1.70855
216 | 8300 24.9 0.17391638 0.12915917 -0.31054187 -0.090691346 1.6136714
217 | 8400 25.2 0.17382715 0.11504449 -0.32285694 -0.10390622 1.5196391
218 | 8500 25.5 0.17441655 0.10977096 -0.32785489 -0.10904197 1.423041
219 | 8600 25.8 0.17552551 0.10950002 -0.30515982 -0.097829901 1.3278802
220 | 8700 26.1 0.17565159 0.12382868 -0.32804391 -0.10210762 1.2330269
221 | 8800 26.4 0.17832953 0.081307133 -0.31380308 -0.11624797 1.1381309
222 | 8900 26.7 0.17801754 0.10200027 -0.27974562 -0.088872672 1.042844
223 | 9000 27 0.17788921 0.1300792 -0.27419009 -0.072055444 0.94771475
224 | 9100 27.3 0.17860872 0.11537032 -0.2803544 -0.082492039 0.85234547
225 | 9200 27.6 0.17841788 0.12414385 -0.25380882 -0.064832486 0.75768498
226 | 9300 27.9 0.17625963 0.13723586 -0.21105379 -0.036908965 0.6636656
227 | 9400 28.2 0.17801505 0.12331144 -0.21061868 -0.043653619 0.56854242
228 | 9500 28.5 0.17714527 0.15181865 -0.2079837 -0.028082526 0.47324755
229 | 9600 28.8 0.17967835 0.13556573 -0.1990823 -0.03175828 0.3783334
230 | 9700 29.1 0.17705493 0.15394524 -0.17111212 -0.0085834388 0.28408232
231 | 9800 29.4 0.17817334 0.17353827 -0.18089706 -0.003679395 0.19037521
232 | 9900 29.7 0.17661448 0.17217651 -0.15407839 0.0090490616 0.095067632
233 | 10000 30 0.17731223 0.19355368 -0.1423432 0.02560524 0
234 | Loop time of 4.74984 on 1 procs for 5000 steps with 8141 atoms
235 |
236 | Performance: 272851.240 tau/day, 1052.667 timesteps/s
237 | 99.1% CPU use with 1 MPI tasks x 1 OpenMP threads
238 |
239 | MPI task timing breakdown:
240 | Section | min time | avg time | max time |%varavg| %total
241 | ---------------------------------------------------------------
242 | Pair | 3.8358 | 3.8358 | 3.8358 | 0.0 | 80.76
243 | Neigh | 0.4183 | 0.4183 | 0.4183 | 0.0 | 8.81
244 | Comm | 0.0051625 | 0.0051625 | 0.0051625 | 0.0 | 0.11
245 | Output | 0.0040231 | 0.0040231 | 0.0040231 | 0.0 | 0.08
246 | Modify | 0.36433 | 0.36433 | 0.36433 | 0.0 | 7.67
247 | Other | | 0.1222 | | | 2.57
248 |
249 | Nlocal: 8141 ave 8141 max 8141 min
250 | Histogram: 1 0 0 0 0 0 0 0 0 0
251 | Nghost: 0 ave 0 max 0 min
252 | Histogram: 1 0 0 0 0 0 0 0 0 0
253 | Neighs: 69249 ave 69249 max 69249 min
254 | Histogram: 1 0 0 0 0 0 0 0 0 0
255 |
256 | Total # of neighbors = 69249
257 | Ave neighs/atom = 8.5062
258 | Neighbor list builds = 185
259 | Dangerous builds = 0
260 |
261 | thermo_style custom step temp pxx pyy cpuremain
262 |
263 | run 400
264 | Per MPI rank memory allocation (min/avg/max) = 3.116 | 3.116 | 3.116 Mbytes
265 | Step Temp Pxx Pyy CPULeft
266 | 10000 0.17731223 0.19351318 -0.14231342 0
267 | 10100 0.17832333 0.20504646 -0.11497251 0.26945114
268 | 10200 0.17837879 0.23324545 -0.06602532 0.18344402
269 | 10300 0.17835133 0.24793925 -0.074760067 0.092408021
270 | 10400 0.17897071 0.24298626 -0.082191499 0
271 | Loop time of 0.369093 on 1 procs for 400 steps with 8141 atoms
272 |
273 | Performance: 280904.857 tau/day, 1083.738 timesteps/s
274 | 99.6% CPU use with 1 MPI tasks x 1 OpenMP threads
275 |
276 | MPI task timing breakdown:
277 | Section | min time | avg time | max time |%varavg| %total
278 | ---------------------------------------------------------------
279 | Pair | 0.29446 | 0.29446 | 0.29446 | 0.0 | 79.78
280 | Neigh | 0.036822 | 0.036822 | 0.036822 | 0.0 | 9.98
281 | Comm | 0.0004859 | 0.0004859 | 0.0004859 | 0.0 | 0.13
282 | Output | 0.00031304 | 0.00031304 | 0.00031304 | 0.0 | 0.08
283 | Modify | 0.027533 | 0.027533 | 0.027533 | 0.0 | 7.46
284 | Other | | 0.009483 | | | 2.57
285 |
286 | Nlocal: 8141 ave 8141 max 8141 min
287 | Histogram: 1 0 0 0 0 0 0 0 0 0
288 | Nghost: 0 ave 0 max 0 min
289 | Histogram: 1 0 0 0 0 0 0 0 0 0
290 | Neighs: 69164 ave 69164 max 69164 min
291 | Histogram: 1 0 0 0 0 0 0 0 0 0
292 |
293 | Total # of neighbors = 69164
294 | Ave neighs/atom = 8.49576
295 | Neighbor list builds = 16
296 | Dangerous builds = 0
297 | Total wall time: 0:00:09
298 |
--------------------------------------------------------------------------------
/tests/test_File.py:
--------------------------------------------------------------------------------
1 | from unittest import TestCase
2 | import numpy as np
3 | import os
4 |
5 | import lammps_logfile
6 |
7 | class TestFileWithLogFile(TestCase):
8 | """Test whether the readings from a supplied log file are correct. Requires the supplied file log.lammps.
9 | """
10 | def setUp(self):
11 | self.log = lammps_logfile.File(os.path.join(os.path.dirname(__file__), "data", "log.lammps"))
12 |
13 | def test_num_entries(self):
14 | self.assertEqual(self.log.get_num_partial_logs(), 3)
15 |
16 | def test_len_partial_logs(self):
17 | step = self.log.get("Step", -1)
18 | self.assertEqual(len(step), 5)
19 | step = self.log.get("Step", 0)
20 | self.assertEqual(len(step), 51)
21 | step = self.log.get("Step", 1)
22 | self.assertEqual(len(step), 51)
23 | step = self.log.get("Step", 2)
24 | self.assertEqual(len(step), 5)
25 |
26 | def test_keyword_partial_logs(self):
27 | keyword0 = ["Step", "Time", "Temp", "Pxx", "Pyy", "CPULeft"]
28 | for keyword in keyword0:
29 | self.assertIsNotNone(self.log.get(keyword, 0))
30 | self.assertIsNone(self.log.get("Press", 0))
31 |
32 | keyword1 = ["Step", "Time", "Temp", "Pxx", "Pyy", "Press", "CPULeft"]
33 | for keyword in keyword1:
34 | self.assertIsNotNone(self.log.get(keyword, 1))
35 |
36 | keyword2 = ["Step", "Temp", "Pxx", "Pyy", "CPULeft"]
37 | for keyword in keyword2:
38 | self.assertIsNotNone(self.log.get(keyword, 2))
39 | self.assertIsNone(self.log.get("Press", 2))
40 | self.assertIsNone(self.log.get("Time", 2))
41 |
42 | def test_step_entries_contents(self):
43 | np.testing.assert_equal(self.log.get("Step", 0), np.arange(0,5001, 100))
44 | np.testing.assert_equal(self.log.get("Step", 1), np.arange(5000,10001, 100))
45 | np.testing.assert_equal(self.log.get("Step", 2), np.arange(10000,10401, 100))
46 |
47 | def test_get_keywords(self):
48 | self.assertListEqual(self.log.get_keywords(), sorted(["Step", "Temp", "Pxx", "Pyy", "CPULeft"]))
49 | self.assertListEqual(self.log.get_keywords(run_num=0), sorted(["Step", "Time", "Temp", "Pxx", "Pyy", "CPULeft"]))
50 | self.assertListEqual(self.log.get_keywords(run_num=1), sorted(["Step", "Time", "Temp", "Pxx", "Pyy", "Press", "CPULeft"]))
51 | self.assertListEqual(self.log.get_keywords(run_num=2), sorted(["Step", "Temp", "Pxx", "Pyy", "CPULeft"]))
--------------------------------------------------------------------------------