├── .gitattributes
├── LICENSE
├── README.md
├── _config.yml
├── lammps_input_files
├── BNC.tersoff
├── force.in
├── forces.in
├── onelayer.data
└── relax_thermal.in
├── scripts
├── Makefile
└── compactify_vels.cpp
├── sdhc
├── SHC_generate.py
├── __init__.py
├── __main__.py
├── __version__.py
└── force_calculate.py
└── setup.py
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/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 | When I have time I will finish the README.md.
2 |
3 | Most codes are self-explanatory.
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-slate
2 | title: Welcome to Spectral-decomposition-python-tools homepage!!!
3 |
--------------------------------------------------------------------------------
/lammps_input_files/BNC.tersoff:
--------------------------------------------------------------------------------
1 | # DATE: 2013-03-21 CONTRIBUTOR: Cem Sevik CITATION: Kinaci, Haskins, Sevik and Cagin, Phys Rev B, 86, 115410 (2012)
2 | # Tersoff parameters for B, C, and BN-C hybrid based graphene like nano structures
3 | # multiple entries can be added to this file, LAMMPS reads the ones it needs
4 |
5 | # these entries are in LAMMPS "metal" units:
6 | # A,B = eV; lambda1,lambda2,lambda3 = 1/Angstroms; R,D = Angstroms
7 | # other quantities are unitless
8 |
9 | # Cem Sevik (csevik at anadolu.edu.tr) takes full blame for this
10 | # file. It specifies B-N, B-C, and N-C interaction parameters
11 | # generated and published by the reseacrh group of Prof. Tahir Cagin.
12 |
13 | # 1. Physical Review B 84, 085409 2011
14 | # Characterization of thermal transport in low-dimensional boron nitride nanostructures,
15 | #
16 |
17 | # 2. Physical Review B 86, 075403 2012
18 | # Influence of disorder on thermal transport properties of boron nitride nanostructures
19 | #
20 |
21 | # 3. Physical Review B 86, 075403 2012, Please see for further information about B-C and N-C parameters
22 | # Thermal conductivity of BN-C nanostructures
23 | #
24 |
25 | # The file also specifies C-C, interaction parameters
26 | # generated and published by the reseacrh group of Dr. D. A. Broido
27 | # Physical Review B 81, 205441 2010
28 | # Optimized Tersoff and Brenner empirical potential parameters for
29 | # lattice dynamics and phonon thermal transport in carbon nanotubes and graphene
30 |
31 | # Users in referring the full parameters can cite the full parameter paper (3) as:
32 | # A. Kinaci, J. B. Haskins, C. Sevik, T. Cagin, Physical Review B 86, 115410 (2012)
33 | # Thermal conductivity of BN-C nanostructures
34 | #
35 |
36 | # format of a single entry (one or more lines):
37 | # element 1, element 2, element 3,
38 | # m, gamma, lambda3, c, d, costheta0, n, beta, lambda2, B, R, D, lambda1, A
39 |
40 | N B B 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.199 340.00 1.95 0.05 3.568 1380.0
41 | N B N 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.199 340.00 1.95 0.05 3.568 1380.0
42 | N B C 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.199 340.00 1.95 0.05 3.568 1380.0
43 |
44 | B N B 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.199 340.00 1.95 0.05 3.568 1380.0
45 | B N N 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.199 340.00 1.95 0.05 3.568 1380.0
46 | B N C 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.199 340.00 1.95 0.05 3.568 1380.0
47 |
48 | N N B 3.0 1.0 0.0 17.7959 5.9484 0.00000 0.6184432 0.019251 2.6272721 138.77866 2.0 0.1 2.8293093 128.86866
49 | N N N 3.0 1.0 0.0 17.7959 5.9484 0.00000 0.6184432 0.019251 2.6272721 138.77866 2.0 0.1 2.8293093 128.86866
50 | N N C 3.0 1.0 0.0 17.7959 5.9484 0.00000 0.6184432 0.019251 2.6272721 138.77866 2.0 0.1 2.8293093 128.86866
51 |
52 | B B B 3.0 1.0 0.0 0.52629 0.001587 0.5 3.9929061 1.6e-6 2.0774982 43.132016 2.0 0.1 2.2372578 40.0520156
53 | B B N 3.0 1.0 0.0 0.52629 0.001587 0.5 3.9929061 1.6e-6 2.0774982 43.132016 2.0 0.1 2.2372578 40.0520156
54 | B B C 3.0 1.0 0.0 0.52629 0.001587 0.5 3.9929061 1.6e-6 2.0774982 43.132016 2.0 0.1 2.2372578 40.0520156
55 |
56 | C C C 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2119 430.00 1.95 0.15 3.4879 1393.6
57 | C C B 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2119 430.00 1.95 0.15 3.4879 1393.6
58 | C C N 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2119 430.00 1.95 0.15 3.4879 1393.6
59 |
60 | C B B 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2054 339.068910 1.95 0.10 3.5279 1386.78
61 | C B N 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2054 339.068910 1.95 0.10 3.5279 1386.78
62 | C B C 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2054 339.068910 1.95 0.10 3.5279 1386.78
63 |
64 | C N B 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2054 387.575152 1.95 0.10 3.5279 1386.78
65 | C N N 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2054 387.575152 1.95 0.10 3.5279 1386.78
66 | C N C 3.0 1.0 0.0 3.8049e4 4.3484 -0.93000 0.72751 1.5724e-7 2.2054 387.575152 1.95 0.10 3.5279 1386.78
67 |
68 | B C C 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.2054 339.068910 1.95 0.10 3.5279 1386.78
69 | B C B 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.2054 339.068910 1.95 0.10 3.5279 1386.78
70 | B C N 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.2054 339.068910 1.95 0.10 3.5279 1386.78
71 |
72 | N C C 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.2054 387.575152 1.95 0.10 3.5279 1386.78
73 | N C B 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.2054 387.575152 1.95 0.10 3.5279 1386.78
74 | N C N 3.0 1.0 0.0 25000 4.3484 -0.89000 0.72751 1.25724e-7 2.2054 387.575152 1.95 0.10 3.5279 1386.78
75 |
--------------------------------------------------------------------------------
/lammps_input_files/force.in:
--------------------------------------------------------------------------------
1 | ## ***************** Initialization # basis ***************
2 | units metal
3 | dimension 3
4 | boundary p p p
5 | atom_style atomic
6 |
7 | # ****************** Read restart file *****************
8 |
9 | read_restart optimize.restart # The statement "atom_modify map hash" must be added to the 'in file' that generates the restart file
10 |
11 | # mass
12 | # First layer
13 |
14 | mass 1 10.811000 # B1
15 | mass 2 12.010700 # C1
16 | mass 3 14.006700 # N1
17 |
18 | # ******************* Define a few parameters **********************
19 |
20 | variable T equal 300 # Average temperature 300K
21 | variable DT equal 0.0005 # Timestep 0.5fs (Read from the restart file)
22 |
23 | # ******************* Fix some atoms to avoid drift ******************
24 |
25 | variable filetowrite string Fij.dat # For generating the force constant
26 |
27 | # ********************* Potential function setting *****************
28 |
29 | pair_style tersoff
30 | pair_coeff * * BNC.tersoff B C N
31 |
32 | timestep ${DT}
33 |
34 | # ************************* The following to divide block ***********************
35 | # ************************* For Y direction **************************************
36 |
37 | variable y_max equal ly
38 | variable P equal ${y_max}/2-100
39 | variable P1 equal ${y_max}/2+100
40 |
41 | variable tmp1 equal ${P1}-${P}
42 | variable tmp equal ${tmp1}/40
43 | variable middle equal ${y_max}/2
44 |
45 | variable L1 equal ${P}+3*${tmp}
46 | variable R1 equal ${P1}-3*${tmp}
47 |
48 | region lfixed block INF INF INF ${P} INF INF units box
49 | region rfixed block INF INF ${P1} INF INF INF units box
50 |
51 | region hot block INF INF ${P} ${L1} INF INF units box
52 | region cold block INF INF ${R1} ${P1} INF INF units box
53 |
54 | region fixed union 2 lfixed rfixed
55 |
56 | region main block INF INF ${P} ${P1} INF INF units box
57 |
58 | region main_nvt block INF INF ${L1} ${R1} INF INF units box
59 |
60 |
61 | group lfixed region lfixed
62 | group rfixed region rfixed
63 | group hot region hot
64 | group cold region cold
65 |
66 | group main region main
67 | group main_nvt region main_nvt
68 |
69 | ## ***************** Frozen atomic group **************
70 |
71 | group freeze region fixed
72 |
73 | ##***************** Velocity groups for transmission calculation *****************
74 |
75 | variable dmid equal 6 ## Set to 6 (A) here
76 | variable mid_left equal ${middle}-${dmid}
77 | variable mid_right equal ${middle}+${dmid}
78 |
79 | region int_L block INF INF ${mid_left} ${middle} INF INF units box
80 | region int_R block INF INF ${middle} ${mid_right} INF INF units box
81 |
82 | group interface_L region int_L
83 | group interface_R region int_R
84 | group interface union interface_L interface_R
85 |
86 | ## ************** Freeze (Freeze some of the atoms of the model) **************
87 |
88 | velocity freeze set 0.0 0.0 0.0 units box
89 | fix 3 freeze nve/noforce
90 |
91 | ## *************** Calculate some thermodymanic quantities *******************
92 |
93 | compute fxfyfz interface property/atom fx fy fz
94 | compute fxs interface property/atom fx
95 | compute fys interface property/atom fy
96 | compute fzs interface property/atom fz
97 |
98 | ## **************** Sampling data and run 0 *****************
99 |
100 | fix 1 main nve
101 |
102 | variable N equal "count(all)"
103 | variable NL equal "count(interface_L)"
104 | variable NR equal "count(interface_R)"
105 |
106 | print "NL ${NL}"
107 | print "NR ${NR}"
108 |
109 |
--------------------------------------------------------------------------------
/lammps_input_files/forces.in:
--------------------------------------------------------------------------------
1 | ## ***************** Initialization # basis ***************
2 | units metal
3 | dimension 3
4 | boundary p p p
5 | atom_style atomic
6 | atom_modify map hash
7 |
8 | # ****************** Read restart file *****************
9 |
10 | read_restart optimize.restart # The statement "atom_modify map hash" must be added to the 'in file' that generates the restart file
11 |
12 | # mass
13 | # First layer
14 |
15 | mass 1 10.811000 # B1
16 | mass 2 12.010700 # C1
17 | mass 3 14.006700 # N1
18 |
19 | # ******************* Define a few parameters **********************
20 |
21 | variable T equal 300 # Average temperature 300K
22 | variable DT equal 0.0005 # Timestep 0.5fs (Read from the restart file)
23 |
24 | # ******************* Fix some atoms to avoid drift ******************
25 |
26 | variable filetowrite string Fij.dat # For generating the force constant
27 |
28 | # ********************* Potential function setting *****************
29 |
30 | pair_style tersoff
31 | pair_coeff * * BNC.tersoff B C N
32 |
33 | timestep ${DT}
34 |
35 | # ************************* The following to divide block ***********************
36 | # ************************* For Y direction **************************************
37 |
38 | variable y_max equal ly
39 | variable P equal ${y_max}/2-100
40 | variable P1 equal ${y_max}/2+100
41 |
42 | variable tmp1 equal ${P1}-${P}
43 | variable tmp equal ${tmp1}/40
44 | variable middle equal ${y_max}/2
45 |
46 | variable L1 equal ${P}+3*${tmp}
47 | variable R1 equal ${P1}-3*${tmp}
48 |
49 | region lfixed block INF INF INF ${P} INF INF units box
50 | region rfixed block INF INF ${P1} INF INF INF units box
51 |
52 | region hot block INF INF ${P} ${L1} INF INF units box
53 | region cold block INF INF ${R1} ${P1} INF INF units box
54 |
55 | region fixed union 2 lfixed rfixed
56 |
57 | region main block INF INF ${P} ${P1} INF INF units box
58 |
59 | region main_nvt block INF INF ${L1} ${R1} INF INF units box
60 |
61 |
62 | group lfixed region lfixed
63 | group rfixed region rfixed
64 | group hot region hot
65 | group cold region cold
66 |
67 | group main region main
68 | group main_nvt region main_nvt
69 |
70 | ## ***************** Frozen atomic group **************
71 |
72 | group freeze region fixed
73 |
74 | ##***************** Velocity groups for transmission calculation *****************
75 |
76 | variable dmid equal 6 ## Set to 6 (A) here
77 | variable mid_left equal ${middle}-${dmid}
78 | variable mid_right equal ${middle}+${dmid}
79 |
80 | region int_L block INF INF ${mid_left} ${middle} INF INF units box
81 | region int_R block INF INF ${middle} ${mid_right} INF INF units box
82 |
83 | group interface_L region int_L
84 | group interface_R region int_R
85 | group interface union interface_L interface_R
86 |
87 | ## ************** Freeze (Freeze some of the atoms of the model) **************
88 |
89 | velocity freeze set 0.0 0.0 0.0 units box
90 | fix 3 freeze nve/noforce
91 |
92 | ## *************** Calculate some thermodymanic quantities *******************
93 |
94 | compute fxfyfz interface property/atom fx fy fz
95 | compute fxs interface property/atom fx
96 | compute fys interface property/atom fy
97 | compute fzs interface property/atom fz
98 |
99 | ## **************** Sampling data and run 0 *****************
100 |
101 | fix 1 main nve
102 |
103 | variable N equal "count(all)"
104 | variable NL equal "count(interface_L)"
105 | variable NR equal "count(interface_R)"
106 |
107 | ## ****************** Initialize groups- ********************
108 |
109 | group atoms_id id 1
110 |
111 | variable hstep equal 0.01 # Amount of displacement
112 | variable hstepm2 equal -2*v_hstep # Negative
113 |
114 | print 'hstepm2 = ${hstepm2}' # Print it if you need
115 |
116 | shell rm ${filetowrite}
117 |
118 | dump helpdump interface custom 1 ${filetowrite} id c_fxs c_fys c_fzs
119 | dump_modify helpdump sort id
120 | dump_modify helpdump append yes
121 |
122 | ## ***************** Write the interface particle id and type to ${filetowrite} ****************
123 |
124 | print "NL ${NL}" append ${filetowrite}
125 | print "NR ${NR}" append ${filetowrite}
126 |
127 | label loop_i
128 |
129 | variable i loop $N
130 |
131 | variable yi equal y[${i}]
132 | variable boolleft equal (y[${i}]<${middle})&&(y[${i}]>=${mid_left})
133 | variable boolright equal (y[${i}]>${middle})&&(y[${i}]<=${mid_right})
134 | # print "${i} ${boolleft} ${boolright}" # Uncomment if you need to visualize data
135 | if "${boolleft}" then &
136 | "print '${i} 1' append ${filetowrite}"
137 | if "${boolright}" then &
138 | "print '${i} 2' append ${filetowrite}"
139 | next i
140 |
141 | jump SELF loop_i
142 |
143 | ## ***************** Loop over atoms on one side, compute forces in all others *************
144 |
145 | print "HSTEP ${hstep}" append ${filetowrite}
146 | thermo_modify flush yes
147 |
148 | variable counter equal 0 ## Define a counter
149 |
150 | ## Next loop function
151 |
152 | label loop_j
153 |
154 | variable j loop $N
155 |
156 | variable yi equal y[${j}]
157 | variable boolleft equal (${yi}<${middle})&&(${yi}>=${mid_left})
158 | variable boolright equal (${yi}>${middle})&&(${yi}<=${mid_right})
159 |
160 | # print "${j} ${boolleft} ${boolright}" # Uncomment if you need to visualize data
161 | if "!${boolleft}" then &
162 | "next j" &
163 | "jump SELF loop_j" &
164 | "jump SELF final_break"
165 | group atoms_id delete
166 | group atoms_id id ${j}
167 |
168 | # ********* X-direction displacement to positive and negative direction **********
169 |
170 | displace_atoms atoms_id move ${hstep} 0 0
171 | variable counter equal ${counter}+1
172 | reset_timestep ${counter}
173 | print "counter=${counter}"
174 | run 0 ## Update the forces in the compute
175 |
176 | displace_atoms atoms_id move ${hstepm2} 0 0
177 | variable counter equal ${counter}+1
178 | reset_timestep ${counter}
179 | print "counter=${counter}"
180 | run 0 ## Update the forces in the compute
181 |
182 | displace_atoms atoms_id move ${hstep} 0 0
183 |
184 | # ********* Y-direction displacement to positive and negative direction **********
185 |
186 | displace_atoms atoms_id move 0 ${hstep} 0
187 | variable counter equal ${counter}+1
188 | reset_timestep ${counter}
189 | print "counter=${counter}"
190 | run 0 ## Update the forces in the compute
191 |
192 | displace_atoms atoms_id move 0 ${hstepm2} 0
193 | variable counter equal ${counter}+1
194 | reset_timestep ${counter}
195 | print "counter=${counter}"
196 | run 0 ## Update the forces in the compute
197 |
198 | displace_atoms atoms_id move 0 ${hstep} 0
199 |
200 | # ********* Z-direction displacement to positive and negative direction **********
201 |
202 | displace_atoms atoms_id move 0 0 ${hstep}
203 | variable counter equal ${counter}+1
204 | reset_timestep ${counter}
205 | print "counter=${counter}"
206 | run 0 ## Update the forces in the compute
207 |
208 | displace_atoms atoms_id move 0 0 ${hstepm2}
209 | variable counter equal ${counter}+1
210 | reset_timestep ${counter}
211 | print "counter=${counter}"
212 | run 0 ## Update the forces in the compute
213 |
214 | displace_atoms atoms_id move 0 0 ${hstep}
215 |
216 | next j
217 | jump SELF loop_j
218 | label final_break
--------------------------------------------------------------------------------
/lammps_input_files/relax_thermal.in:
--------------------------------------------------------------------------------
1 | ## ***************** Initialization # basis ***************
2 | units metal
3 | dimension 3
4 | boundary p p p
5 | atom_style atomic
6 | atom_modify map hash
7 | # ****************** read data *****************
8 | read_data onelayer.data
9 |
10 | # mass
11 | # First layer
12 | mass 1 10.811000 # B1
13 | mass 2 12.010700 # C1
14 | mass 3 14.006700 # N1
15 |
16 | # ******************* Define a few parameters **********************
17 |
18 | variable T equal 300 # average temperature 300K
19 | variable DT equal 0.0005 # timestep 0.5fs (Read from the restart file)
20 | variable T_low equal 270 # Heat sink 270K
21 | variable T_hight equal 330 # Heat source 330K
22 |
23 | variable restartfile string optimize.restart # Write the restart file in preparation for generating the force constant
24 |
25 | # ********************* Potential function setting *****************
26 |
27 | pair_style tersoff
28 | pair_coeff * * BNC.tersoff B C N
29 |
30 | # ********************* thermo output ************************
31 |
32 | thermo 1000
33 | thermo_style custom step temp lx ly lz press vol pxx pyy pzz pe ke etotal #energy output
34 |
35 | ## *********************** Initialization ##relaxation< ***********************
36 | ## *********************** Optimize at 0 K ***********************
37 | ## *********************** Static equilibrium **************************
38 |
39 | dump 1 all custom 1000 dump.minimization id type x y z # Output the minimum structure, see whether the structure is reasonable
40 | dump_modify 1 sort id
41 |
42 | #neighbor 0.3 bin
43 | #neigh_modify once yes ### Generally no Settings are required
44 |
45 | fix 1 all nve
46 | min_style cg
47 | minimize 1.0e-5 1.0e-8 1000000 1000000
48 | undump 1
49 | unfix 1
50 |
51 | # ************************* Set velocity at 300K **********************
52 |
53 | reset_timestep 0 # Time reset
54 | velocity all create ${T} 619206 mom yes rot yes dist gaussian # Setting Random seed
55 |
56 | # ************************* The following to divide block ***********************
57 | # ************************* For Y direction **************************************
58 |
59 | variable y_max equal ly
60 | variable P equal ${y_max}/2-100
61 | variable P1 equal ${y_max}/2+100
62 |
63 | variable tmp1 equal ${P1}-${P}
64 | variable tmp equal ${tmp1}/40
65 |
66 | variable L1 equal ${P}+3*${tmp}
67 | variable R1 equal ${P1}-3*${tmp}
68 |
69 | region lfixed block INF INF INF ${P} INF INF units box
70 | region rfixed block INF INF ${P1} INF INF INF units box
71 |
72 | region hot block INF INF ${P} ${L1} INF INF units box
73 | region cold block INF INF ${R1} ${P1} INF INF units box
74 |
75 | region fixed union 2 lfixed rfixed
76 |
77 | region main block INF INF ${P} ${P1} INF INF units box
78 |
79 | region main_nvt block INF INF ${L1} ${R1} INF INF units box
80 |
81 |
82 | group lfixed region lfixed
83 | group rfixed region rfixed
84 | group hot region hot
85 | group cold region cold
86 |
87 | group main region main
88 | group main_nvt region main_nvt
89 |
90 | ## ***************** Frozen atomic group **************
91 |
92 | group freeze region fixed
93 |
94 | ## ***************** Group layer_1 (Gr) *****************
95 |
96 | #group Gr type 4 # If you need
97 |
98 | ## ***************** Group layer_2 (Gr_Hbn) **************
99 |
100 | group Gr_Hbn type 1 2 3
101 |
102 | ##***************** Divide the zone into blocks for extracting the temperature blocks *****************
103 |
104 | variable average_40 equal (${P1}-${P})/40
105 | variable average_50 equal (${P1}-${P})/50
106 | variable middle equal ${y_max}/2
107 | variable average_1 equal (${middle}-${P})/20
108 | variable average_2 equal (${P1}-${middle})/20
109 |
110 | region main_1 block INF INF ${P} ${middle} INF INF units box
111 | region main_2 block INF INF ${middle} ${P1} INF INF units box
112 | region main_main block INF INF ${P} ${P1} INF INF units box
113 |
114 | group main_1 region main_1
115 | group main_2 region main_2
116 | group main_main region main_main
117 |
118 | ##***************** Velocity groups for transmission calculation *****************
119 |
120 | variable dmid equal 6 ## Set to 6 (A) here
121 | variable mid_left equal ${middle}-${dmid}
122 | variable mid_right equal ${middle}+${dmid}
123 |
124 | region int_L block INF INF ${mid_left} ${middle} INF INF units box
125 | region int_R block INF INF ${middle} ${mid_right} INF INF units box
126 |
127 | group interface_L region int_L
128 | group interface_R region int_R
129 | group interface union interface_L interface_R
130 |
131 | ## ************** Freeze (Freeze some of the atoms of the model) **************
132 |
133 | velocity freeze set 0.0 0.0 0.0 units box
134 | fix 3 freeze nve/noforce
135 |
136 | ## *************** Calculate some thermodymanic quantities *******************
137 |
138 | compute Thot hot temp/region hot
139 | compute Tcold cold temp/region cold
140 | compute Ftemp freeze temp/region fixed
141 |
142 | # **************** Compute temperature *****************
143 |
144 | compute ALLKe all ke/atom
145 | variable KB equal 8.625e-5
146 | variable TEMP atom c_ALLKe/1.5/${KB}
147 | fix Totaltemperatom all ave/atom 10 50000 500000 v_TEMP
148 |
149 | # **************** Now optimize at 300K ********************
150 | # **************** The 1nd equilibration run ********************
151 |
152 | fix 1 main nvt temp ${T} ${T} 0.1
153 | dump 1 all custom 500000 dump.optimize id type x y z f_Totaltemperatom
154 | dump_modify 1 sort id ## Sort each atom
155 |
156 | thermo_style custom step temp lx ly lz c_Thot c_Tcold c_Ftemp press pe ke etotal
157 | thermo 1000
158 |
159 | ## Set the time_step
160 |
161 | timestep ${DT}
162 |
163 | #restart
164 | #restart 500000 optimize.*.restart
165 |
166 | run 3000000
167 |
168 | undump 1
169 | unfix 1
170 |
171 | #minimize 0 1.0e-3 1000 1000 # (optional)
172 | min_style cg
173 | minimize 1.0e-5 1.0e-8 1000000 1000000
174 |
175 | run 0
176 |
177 | write_restart ${restartfile}
178 |
179 | write_data data.pos nocoeff
180 |
181 | variable v1 equal xlo
182 | variable v2 equal xhi
183 | variable v3 equal ylo
184 | variable v4 equal yhi
185 | variable v5 equal zlo
186 | variable v6 equal zhi
187 | print "************** The system boundaries are ****************"
188 | print " X-direction is ---------* ${v1} ${v2} *-----------(A)"
189 | print " Y-direction is ---------* ${v3} ${v4} *-----------(A)"
190 | print " Z-direction is ---------* ${v5} ${v6} *-----------(A)"
191 |
192 | print "*********** You can use the restart file for the 2nd equilibration run (for thermal transport) **************"
193 | print "****************** You can also use the restart file to generate force constant files **************"
194 |
195 |
196 | # ************************ The second stage **********************
197 | # ************************ The 2nd equilibration run **********************
198 | # ************************ Write a shell script to generate velocity random number *******************
199 |
200 | variable hot_velocity equal 611535
201 | variable cold_velocity equal 27117
202 | variable random_seed equal 0.1 ## To get excellent kinetic properties, this is a good choice
203 |
204 | fix 1 main nve
205 | fix Hot hot langevin ${T_hight} ${T_hight} ${random_seed} ${hot_velocity} tally yes
206 | fix Cold cold langevin ${T_low} ${T_low} ${random_seed} ${cold_velocity} tally yes #langevin
207 |
208 | ## Uncomment and use VMD to check that interface definitions are what you expect
209 |
210 | dump 1 all custom 500000 dump.relaxation id type x y z f_Totaltemperatom
211 | dump_modify 1 sort id
212 |
213 | dump 2 main_main custom 500000 dump.main id type x y z f_Totaltemperatom
214 | dump_modify 2 sort id
215 |
216 | dump 3 main_1 custom 500000 dump.hot id type x y z f_Totaltemperatom
217 | dump_modify 3 sort id
218 |
219 | dump 4 main_2 custom 500000 dump.cold id type x y z f_Totaltemperatom
220 | dump_modify 4 sort id
221 |
222 | ## Write interfacial structure to file for Ovito visualization
223 |
224 | dump 5 interface custom 500000 dump.interface id type x y z f_Totaltemperatom
225 | dump_modify 5 sort id
226 |
227 |
228 | variable tdiff equal c_Thot-c_Tcold
229 |
230 | thermo_style custom step temp lx ly lz c_Thot c_Tcold c_Ftemp f_Hot f_Cold v_tdiff
231 | thermo 1000
232 |
233 | run 4000000
234 |
235 | unfix Totaltemperatom
236 | undump 1
237 | undump 2
238 | undump 3
239 | undump 4
240 | undump 5
241 |
242 | # ************************** Collect Velocities for the calculation of force constants *************************
243 |
244 | variable dn equal 10
245 |
246 | dump vels interface custom ${dn} vels.dat id type vx vy vz
247 | dump_modify vels format line "%d %d %0.8g %0.8g %0.8g"
248 | dump_modify vels sort id
249 |
250 | dump vels_L interface_L custom ${dn} force_vels_left.dat id type fx fy fz vx vy vz
251 | dump_modify vels_L format line "%d %d %0.8g %0.8g %0.8g %0.8g %0.8g %0.8g"
252 | dump_modify vels_L sort id
253 |
254 | dump vels_R interface_R custom ${dn} force_vels_right.dat id type fx fy fz vx vy vz
255 | dump_modify vels_R format line "%d %d %0.8g %0.8g %0.8g %0.8g %0.8g %0.8g"
256 | dump_modify vels_R sort id
257 |
258 | run 500000
259 |
260 | undump vels
261 | undump vels_L
262 | undump vels_R
263 |
264 | # *************************** The third stage ************************
265 | # **************************** Reset langevin thermostats to zero energy accumulation ******************
266 | # **************************** Thermal conductivity (NEMD) calculation ************************
267 | # **************************** Reset time step *************************
268 |
269 | reset_timestep 0
270 |
271 | # Reset langevin thermostats
272 |
273 | fix Hot hot langevin ${T_hight} ${T_hight} ${random_seed} ${hot_velocity} tally yes
274 | fix Cold cold langevin ${T_low} ${T_low} ${random_seed} ${cold_velocity} tally yes #langevin
275 |
276 | thermo_style custom step temp lx ly lz c_Thot c_Tcold c_Ftemp f_Hot f_Cold v_tdiff
277 | thermo_modify lost warn flush yes
278 |
279 | fix hot1 hot ave/time 10 100 1000 f_Hot file hot.txt
280 | fix cold1 cold ave/time 10 100 1000 f_Cold file cold.txt
281 |
282 | compute BLOCKSZ_40 main_main chunk/atom bin/1d y lower ${average_40} units box
283 |
284 | fix T_PROFILEZ_40 main_main ave/chunk 100 30000 3000000 BLOCKSZ_40 v_TEMP file temp_40.txt
285 |
286 | compute BLOCKSZ_50 main_main chunk/atom bin/1d y lower ${average_50} units box
287 |
288 | fix T_PROFILEZ_50 main_main ave/chunk 100 30000 3000000 BLOCKSZ_50 v_TEMP file temp_50.txt
289 |
290 | compute BLOCKS_1 main_1 chunk/atom bin/1d y lower ${average_1} units box
291 | fix T_PROFILE_1 main_1 ave/chunk 100 30000 3000000 BLOCKS_1 v_TEMP file temp_1.txt
292 |
293 | compute BLOCKSZ_2 main_2 chunk/atom bin/1d y lower ${average_2} units box
294 |
295 | fix T_PROFILEZ_2 main_2 ave/chunk 100 30000 3000000 BLOCKSZ_2 v_TEMP file temp_2.txt
296 |
297 | ## ********************* Run enough time ***********************
298 |
299 | restart 3000000 thermal.*.restart
300 |
301 | run 6000000
302 |
--------------------------------------------------------------------------------
/scripts/Makefile:
--------------------------------------------------------------------------------
1 | CC=g++
2 | CCFlags=-Wall
3 | EXECUTABLE=compactify_vels
4 |
5 | all:
6 | $(CC) $(CCFLAGS) compactify_vels.cpp -o $(EXECUTABLE)
7 | clean:
8 | rm -f compactify_vels
9 |
10 |
--------------------------------------------------------------------------------
/scripts/compactify_vels.cpp:
--------------------------------------------------------------------------------
1 | // -*- coding: utf-8 -*-
2 | // Kimmo Sääskilahti, 2015
3 |
4 | // Usage: compactify_vels lammps_dump_file [output_file]
5 |
6 | /*
7 | Program writes the velocity data file produced by LAMMPS
8 | in a more compact, ravelled form without the additional data
9 | appearing for each time step in the dump file. The assumed commands used for dumping the velocities from LAMMPS is as follows:
10 |
11 | dump vels interface custom dt_dump filename.vels.dat id type vx vy vz
12 | dump_modify vels format "%d %d %.8g %.8g %.8g"
13 | dump_modify vels sort id
14 |
15 | "interface" is the group of atoms at the interface where SHC is calculated
16 | "dt_dump" is the sampling time step (integer) specifying the maximum frequency
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | using namespace std;
24 |
25 | void skip_lines(istream&,size_t);
26 |
27 |
28 |
29 | int main(int argc,char** argv){
30 |
31 |
32 |
33 | if(argc==1){
34 | cout<<"Usage: Give the filenames on the command line."<>filename;
52 | //cout<<"Reading from file "<>filename2;
55 |
56 | cout<<"Writing to file "<>t0;
74 | cout<<"The initial time step is "<> N;
79 | cout<<"The number of atoms is "<>ids[i];
86 | getline(file1,str); // Skip the rest of the line
87 | //cout<>t1;
91 | cout<<"The difference of time steps is "<::eof()){ // The next character is not EOF
121 | if ((iter)%100000==0)
122 | cout<<"iter="<>id>>type>>vx>>vy>>vz;
133 | //file2< 0: # Not the first chunk
369 | self.NChunks = k - 1
370 | break
371 | else:
372 | exitFlag = True
373 | self.oms_fft = np.fft.rfftfreq(self.chunkSize, d=self.sampleTimestep) * 2 * np.pi
374 | Nfreqs = np.size(self.oms_fft)
375 | print("Changing chunk size to " + str(int(np.size(velArray) / NDOF)) + "!")
376 |
377 | # Reshape the array so that each row corresponds to different degree of freedom (e.g. particle 1, direction x, y, z etc.)
378 |
379 | velArray = np.reshape(velArray, (NDOF, self.chunkSize), order='F') # Write in column order
380 |
381 | # FFT with respect to the second axis (NOTE THE USE OF RFFT)
382 | velFFT = np.fft.rfft(velArray, axis=1) # axis = 0 for rows, axis = 1 for column
383 | velFFT *= self.sampleTimestep
384 |
385 | self.velsL = np.zeros((3 * self.NL, Nfreqs), dtype = np.complex128)
386 | self.velsR = np.zeros((3 * self.NR, Nfreqs), dtype = np.complex128)
387 |
388 | ## Atoms on the left (self.ids_L is the left interfacial atom indices)
389 |
390 | self.velsL[0::3, :] = velFFT[3 * self.ids_L, :] # X-direction velocity
391 | self.velsL[1::3, :] = velFFT[3 * self.ids_L + 1, :] # Y-direction velocity
392 | self.velsL[2::3, :] = velFFT[3 * self.ids_L + 2, :] # Z-direction velocity
393 |
394 | ## Atoms on the right (self.ids_L is the right interfacial atom indices)
395 |
396 | self.velsR[0::3, :] = velFFT[3 * self.ids_R, :] # X-direction velocity
397 | self.velsR[1::3, :] = velFFT[3 * self.ids_R + 1, :] # Y-direction velocity
398 | self.velsR[2::3, :] = velFFT[3 * self.ids_R + 2, :] # Z-direction velocity
399 |
400 | ## For different direction spectral SHC:
401 | if self.in_plane or self.out_of_plane:
402 |
403 | self._differ_direction()
404 |
405 | # Spectral heat current for the specific chunk
406 | SHC = np.zeros(Nfreqs)
407 |
408 | '''
409 | In formula programming, the SHC here is already the sum of the left and right interface atoms
410 | '''
411 | for ki in range(1, Nfreqs): # Skip the first one with zero frequency
412 | SHC[ki] = -2.0 * np.imag(np.dot(self.velsL[:, ki], np.dot(self.Kij, np.conj(self.velsR[:, ki])))) / self.oms_fft[ki] # np.dot is the matrix product
413 |
414 | # Normalize correctly
415 |
416 | SHC /= (self.chunkSize * self.sampleTimestep)
417 |
418 | # Change units
419 |
420 | SHC *= self.scaleFactor
421 |
422 | # Copy the SHC value before modifying it
423 |
424 | SHC_orig = SHC.copy()
425 |
426 | # Smooth the value
427 |
428 | df = (self.oms_fft[1] - self.oms_fft[0]) / (2 * np.pi) # Angular frequency, positive val (w is the angular frequency)
429 | SHC = self._smoothen(SHC, df, self.widthWin)
430 |
431 | # Time average
432 | if not exitFlag: # If Nfreqs has changed, the running averaging cannot be performed
433 | self.SHC_smooth = (k * self.SHC_smooth + SHC) / (k + 1.0)
434 | # The square
435 | self.SHC_smooth2 = (k * self.SHC_smooth2 + SHC ** 2) / (k + 1.0)
436 | # The non-smoothened average
437 | self.SHC_average = (k * self.SHC_average + SHC_orig) / (k + 1.0)
438 | if self.backupPrefix is not None:
439 | np.save(self.backupPrefix + '_backup_oms.npy', self.oms_fft)
440 | np.save(self.backupPrefix + '_backup_SHC.npy', self.SHC_smooth)
441 | import cPickle as pickle
442 | with open(self.backupPrefix + '_run_PP.pckl', 'w') as pf:
443 | pickle.dump(self, pf)
444 | elif exitFlag and k == 0: # First chunk and new chunk size, needs re-initializing the vectors as Nfreqs may have changed
445 | self.SHC_smooth = SHC
446 | self.SHC_smooth2 = SHC ** 2
447 | self.SHC_average = SHC_orig
448 | self.NChunks = 1
449 | break
450 | else: # This should never be reached
451 | assert False, "SHCPostProc should not reach here (exitFlag=True and k>0)."
452 |
453 | # Calculate the error estimate at each frequency from the between-chunk variances
454 |
455 | if self.NChunks > 1:
456 | print("\nCalculating error estimates.")
457 | samplevar = (self.NChunks / (self.NChunks - 1.0)) * (self.SHC_smooth2 - self.SHC_smooth ** 2)
458 | self.SHC_error = np.sqrt(samplevar) / np.sqrt(self.NChunks)
459 | else:
460 | self.SHC_error = None
461 |
462 | print("\nFinished post-processing.")
463 |
464 | self._toc()
465 |
466 |
467 | if __name__ == "__main__":
468 |
469 | fileprefix = 'Fij.dat'
470 | in_file = 'forces.in' ## The in file for lammps
471 | atomic_velocities_file = 'vels.dat'
472 | compact_velocities_file = 'vels.compact.dat'
473 | frequency_window_width = 2e12 ## Hz
474 |
475 | #*************** eV/ps^2; 1 eV = 1.602e-19 J, 1 ps = 1e-12 s ***************
476 | unit_scaling_factor = 1.602e-19 / 1e-20 * 1e4 ## convert: v*dF/du*v = [A/ps]*[eV/A]/[A]*[A/ps]
477 |
478 | md_timestep = 0.5e-15 ## second
479 | area = 62.119 * 3.35 ## A^2, it depends on your case
480 | Tem_jump = 60 ## 60K is the temperature jump
481 | Kb = 1.380649e-23 ## Boltzmann's constant, J/K
482 |
483 | postprocessor = SHCPostProc(compact_velocities_file,
484 | fileprefix,
485 | dt_md = md_timestep,
486 | scaleFactor = unit_scaling_factor,
487 | LAMMPSDumpFile = atomic_velocities_file,
488 | widthWin = frequency_window_width,
489 | LAMMPSInFile = in_file,
490 | in_plane = False,
491 | out_of_plane = False,
492 | reCalcVels = True,
493 | reCalcFC = True)
494 |
495 | postprocessor.postProcess()
496 |
497 | # Plotting if available
498 |
499 | import matplotlib.pylab as plt
500 | import scipy.integrate as sci # For calculate the area
501 |
502 | # Unit conversion
503 | x_Frequency = postprocessor.oms_fft/(2*np.pi*1.0e12) # Conversion from Hz to THz
504 |
505 | # The unit of heat currents is Joule (J), which is W / Hz
506 | # Calculate the Spectral thermal conductance
507 | y_ITC = postprocessor.SHC_smooth / (1.0e-12 * area * 1.0e-20 * Tem_jump * 1.0e9) # From W to GW (/1.0e9)
508 |
509 | # Calculate the phonon transmission T(w)
510 | T_w = postprocessor.SHC_smooth / (Kb * Tem_jump) # Dimensionless
511 |
512 | # Calculate the accumulated thermal conductance
513 | Freq_number = len(x_Frequency)
514 | accumulated_ITC = []
515 | accumulated_count = 0
516 |
517 | for i in range(Freq_number):
518 | accumulated_count = sci.trapz(y_ITC[0:i], x_Frequency[0:i])
519 | accumulated_ITC.append(accumulated_count)
520 |
521 | print('\nThe accumulated thermal conductance is ' + str(accumulated_count) + ' (GW/m^2/K)')
522 |
523 | # Save the frequencies and smoothened spectral heat currents to text file
524 | np.savetxt('frequencies_and_ITC.txt', np.column_stack((x_Frequency, y_ITC)))
525 | np.savetxt('frequencies_accumulated_ITC.txt', np.column_stack((x_Frequency, accumulated_ITC)))
526 |
527 |
528 | # *************************** Plotting ************************* (It can be reduced to a graph function)
529 | # Phonon transmission T(w)
530 | plt.plot(x_Frequency, T_w, '-', linewidth=3, label="Interfacial Phonon Transmission")
531 | plt.xlabel('w/(2*pi) (THz)')
532 | plt.ylabel('Transmission')
533 | plt.xlim(0, max(x_Frequency)) # Frequency range
534 | plt.ylim(0, max(T_w) + 5) # It depends on your case
535 | plt.legend(fontsize=15, loc='best')
536 | plt.show()
537 | plt.savefig(fileprefix+'_Tw.eps')
538 |
539 | # Spectral thermal conductance
540 | plt.plot(x_Frequency, y_ITC, '-', linewidth=3, label="Spectral thermal conductance")
541 | plt.xlabel('w/(2*pi) (THz)')
542 | plt.ylabel('G(w) (GW/m^2/K/THz)')
543 | plt.xlim(0, max(x_Frequency)) # Frequency range
544 | plt.ylim(0, max(y_ITC)+(max(y_ITC)/2)) # It depends on your case
545 | print('\nThe total thermal conductance is ' + str(sci.trapz(y_ITC, x_Frequency)) + ' (GW/m^2/K)\n')
546 | plt.legend(fontsize=15, loc='best')
547 | plt.show()
548 | plt.savefig(fileprefix+'_SHC.eps')
549 |
550 | # Spectral accumulated thermal conductance
551 | plt.plot(x_Frequency, accumulated_ITC, 'or', label="Accumulated thermal conductance")
552 | plt.xlabel('w/(2*pi) (THz)')
553 | plt.ylabel('G(w) (GW/m^2/K)')
554 | plt.xlim(0, max(x_Frequency)) # Frequency range
555 | plt.ylim(0, accumulated_count + 1) # It depends on your case
556 | plt.legend(fontsize=15, loc='best')
557 | plt.show()
558 | plt.savefig(fileprefix+'_accumulated_ITC.eps')
--------------------------------------------------------------------------------
/sdhc/__init__.py:
--------------------------------------------------------------------------------
1 | from . import SHC_generate as SHCPostProcModule
2 | from .SHC_generate import *
3 | from . import force_calculate as fcCalcModule
4 | from .force_calculate import *
5 |
6 | __all__ = ["__version__"] + fcCalcModule.__all__ + SHCPostProcModule.__all__
7 |
8 | del fcCalcModule
9 | del SHCPostProcModule
--------------------------------------------------------------------------------
/sdhc/__main__.py:
--------------------------------------------------------------------------------
1 | from .SHC_generate import *
2 | from .force_calculate import *
3 |
4 |
5 | def main():
6 | print("Not done yet!")
7 |
8 |
9 | if __name__ == '__main__':
10 | main()
--------------------------------------------------------------------------------
/sdhc/__version__.py:
--------------------------------------------------------------------------------
1 | __version__ = '0.2.0'
--------------------------------------------------------------------------------
/sdhc/force_calculate.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | """
5 | @author: Kimmo Sääskilahti
6 | ksaaskil@gmail.com
7 |
8 | Made some modifications by Liang Ting
9 | liangting.zj@gmail.com
10 | 2020/2/7 14:22:15
11 | """
12 |
13 | import numpy as np
14 | import sys
15 |
16 | __all__ = ["fcCalc"]
17 |
18 | class fcCalc(object):
19 | """
20 | Class for computing force constants between atoms.
21 | Uses the `Python library interface `_
22 | of LAMMPS so you need to have (1) `lammps` in your `PYTHONPATH` and
23 | (2) `liblammps.so` available for the Python package.
24 | :param fileprefix: File prefix (TODO What is this)
25 | :type fileprefix: str
26 | :param restartfile: LAMMPS restart file (The restart file is also required, but here not as an attribute)
27 | :type restartfile: str
28 | """
29 | def __init__(self, fileprefix):
30 |
31 | self.fileprefix = fileprefix
32 | self.Kij = None
33 | self.inds_left = None ## Used to find the index of the atoms on the left
34 | self.inds_right = None ## Used to find the index of the atoms on the right
35 | self.inds_interface = None ## Used to compare with the atomic index in the dump_velovity file
36 | self.ids_L = None ## Used to index the speed ordinal (left)
37 | self.ids_R = None ## Used to index the speed ordinal (right)
38 | self.natoms = None
39 | self.lmp = None ## Python-Lammps interface
40 |
41 | def __enter__(self):
42 | return self
43 |
44 | def __exit__(self, exc_type, exc_val, exc_tb):
45 | return False
46 |
47 | def preparelammps(self, in_lammps = None, w_interface = 6.0, show_log = False):
48 | """
49 | Prepare the LAMMPS object for computing force constants.
50 | :param fileprefix: File prefix (lammps in_file)
51 | :type fileprefix: str
52 | :param w_interface: Width of the area of atoms to include in the interface, defaults to 6.0
53 | :type w_interface: float, optional
54 | :param show_log: Whether to write the log file to the generate_force.log file, if true, no log file will be generated. (default False)
55 | :type show_log: boolean, optional
56 | :return: None
57 | """
58 | from lammps import lammps
59 |
60 | cmd_list = ['-log', 'generate_force.log', '-screen', 'none']
61 |
62 | if not show_log:
63 | cmd_list += ['-echo', 'none']
64 |
65 | self.lmp = lammps(cmdargs = cmd_list)
66 |
67 | if in_lammps is not None:
68 | pass
69 | else:
70 | sys.exit('\n\tFile error: The in file that lammps needs to read does not exist!\n')
71 |
72 | #lines = open(in_lammps,'r').readlines()
73 | #for line in lines: self.lmp.command(line)
74 | """
75 | Do the same as lmp.command(filename) but don't allow the script to be
76 | continued after quit.
77 | """
78 | lines = open(in_lammps,'r').readlines()
79 | for line in lines:
80 | #print(line)
81 | if "quit" in line and line[0] != "#":
82 | sys.exit('\n\tQuit error: It is not appropriate '
83 | 'to exit the execution of the in.file at this time\n') ## Quit lammps if find the keyword 'quit'
84 | else:
85 | self.lmp.command(line)
86 |
87 | # Get the position of the interface, at the middle by default (0.5)
88 |
89 | ylo = self.lmp.extract_global("boxylo", 1)
90 | yhi = self.lmp.extract_global("boxyhi", 1)
91 | #print "Box is [%f,%f]." % (ylo, yhi) # Print the boundaries of the box (optional)
92 |
93 | # These variables (including middle, mid_left, and mid_right) must be predefined in the in_file
94 | middle = self.lmp.extract_variable("middle", "all", 0)
95 | mid_left = self.lmp.extract_variable("mid_left", "all", 0)
96 | mid_right = self.lmp.extract_variable("mid_right", "all", 0) # group = group ID ('all') (ignored for equal-style variables)
97 | w_interface_infile = (mid_right - mid_left)/2
98 |
99 | if (w_interface_infile != w_interface):
100 | sys.exit('\n\t Parameter setting ERROR: The settings for w_interface do '
101 | 'not match those in lammps\n')
102 |
103 | # Coordinates ordered by atom ID
104 | coords_data = self.lmp.gather_atoms("x", 1, 3)
105 |
106 | # Coordinates in a numpy array
107 | coords = np.array(coords_data[:], dtype=np.dtype('f8'))
108 | self.natoms = self.lmp.extract_global("natoms", 0)
109 |
110 | ''' Data structures after rashape
111 |
112 | atom1_x (coords_data[0]) atom1_y (coords_data[1]) atom1_z (coords_data[2])
113 | atom2_x (coords_data[3]) atom2_y (coords_data[4]) atom2_z (coords_data[5])
114 | '''
115 | coords = np.reshape(coords, (self.natoms, 3))
116 |
117 | # Y-coordinates in a Numpy array
118 | ys = coords[:, 1] ## xs=coords[:, 0] , ys = coords[:, 1], zs = coords[:, 2]
119 |
120 | '''
121 | (1) minimize 0 1.0e-3 1000 1000 # (after relaxing the structures to the potential minimum)
122 | run 0
123 | After the structure is completely relaxed, the process of energy minimization must be added
124 |
125 | (2) Since energy minimization may result in different atomic Numbers on the left and right sides of the interface,
126 | the definition of the width of the interface can be fine-tuned.
127 |
128 | (3) The program will automatically identify if the left and right atom ids are the same as the atom id of the dump_velcity_file.
129 | '''
130 | # Atom on the left side?
131 | mask_left = np.logical_and(ys < middle, ys >= mid_left-1) ## return boolean
132 | # Atom on the right side?
133 | mask_right = np.logical_and(ys > middle, ys <= mid_right)
134 |
135 | # Note that these indices differ from atom IDs by a factor of one
136 |
137 | self.inds_left = np.where(mask_left)[0]
138 | self.inds_right = np.where(mask_right)[0]
139 |
140 | # All atom indices sorted by atom ID, duplicates removed
141 | # Note that these indices differ from atom IDs by a factor of one
142 |
143 | self.inds_interface = np.unique(np.concatenate((self.inds_left, self.inds_right)))
144 |
145 | # Where are the atoms of the left atom set
146 |
147 | self.ids_L = np.in1d(self.inds_interface, self.inds_left) # To find the subset
148 | self.ids_L = np.where(self.ids_L)[0] # or np.where(np.in1d(aArray,bArray))[0]
149 |
150 | # Atoms of the right set
151 |
152 | self.ids_R = np.in1d(self.inds_interface, self.inds_right)
153 | self.ids_R = np.where(self.ids_R)[0]
154 |
155 | # Get information from the in file
156 |
157 | N = self.lmp.extract_variable("N", "all", 0)
158 | NL = self.lmp.extract_variable("NL", "all", 0)
159 | NR = self.lmp.extract_variable("NR", "all", 0)
160 |
161 | # Determine whether the number of left and right atoms is equal
162 |
163 | if (len(self.ids_L) != len(self.ids_R) or len(self.ids_L) != NR or len(self.ids_R) != NL):
164 | sys.exit('\n\tLAMMPS SETUP ERROR: Number of atoms on left and right side don\'t match! '
165 | 'Checking the width definition of the interface is an good option.\n')
166 |
167 | def fcCalc(self, hstep):
168 | """
169 | Compute force constants and store to `self.Kij`.
170 | :param hstep: Step to use in finite differences (the finite displacement method)
171 | :type hstep: float
172 | :return: None
173 |
174 | This function reads in the [dFi/duj] force constanst from
175 | LAMMPS compute commands. The structure of the infile should be blocks
176 | of data that are N atoms long. Here, N means the number of atoms in
177 | the interface region. Each atom of the N atoms in the block
178 | is the 'i' index in d^2Fi/duj. The Python_LAMMPS code loops over all atoms j
179 | on the left side of the interface; j in the dFi/duj expression. There
180 | are NL = NR atoms on the left side of the inteface, i.e. the number on
181 | each side should (and MUST) be the same. Each atom on the left side, j, is
182 | looped over; in each loop iteration the atom is moved in the +x, then -x,
183 | then back to equilibrium. Then the atom is moved in the +y, then -y, then
184 | back to equilibrium. Finally, the atom is moved in the +z, then -z, then
185 | back to equilibrium.
186 |
187 | Thus, each line in each block in the file corresponds to an atom i.
188 | Each element in each line is the force felt by the atom in the x, y, and
189 | z direction (the force vector elements). For each block, the atom j is
190 | moved iteratively in the +x, then-x, then +y ... etc.
191 |
192 | The function returns kij, the matrix elements of the force constants
193 | between atoms on either side of the interface.
194 | kij has the shape [3*nr,3*nl] -> [dFi-x,y,z,duj-x,y,z]. Each individual
195 | force constant is defined as:
196 |
197 | dFi_a
198 | ----------
199 | drj_b
200 |
201 | Which is interpreted as the change in force on atom i in the direction
202 | a = (x,y,z) due to the movement of atom j in b=(x,y,z).
203 | Each element of first dimension of the kij matrix corresponds to the
204 | force on atom i due to the movement of atom j in each direction
205 |
206 | dF1_x dF1_x dF1_x dF1_x
207 | ---------- ---------- ---------- ---------- .....
208 | dr1_x dr1_y dr1_z dr2_x
209 |
210 |
211 | dF1_y dF1_y dF1_y dF1_y
212 | ---------- ---------- ---------- ---------- .....
213 | dr1_x dr1_y dr1_z dr2_x
214 |
215 |
216 | dF1_z dF1_z dF1_z dF1_z
217 | ---------- ---------- ---------- ---------- .....
218 | dr1_x dr1_y dr1_z dr2_x
219 |
220 |
221 | dF2_x dF2_x dF2_x dF2_x
222 | ---------- ---------- ---------- ---------- .....
223 | dr1_x dr1_y dr1_z dr2_x
224 |
225 | : : : :
226 | : : : :
227 | """
228 | lmp = self.lmp
229 | natoms = self.natoms
230 | inds_left = self.inds_left
231 | inds_right = self.inds_right
232 |
233 | # One-dimensional indices of the atoms on the right side (Y-coordinates)
234 |
235 | inds_right_1d = np.concatenate((3 * inds_right, 3 * inds_right + 1, 3 * inds_right + 2))
236 | inds_right_1d = np.sort(inds_right_1d)
237 |
238 | Kij = np.zeros((len(inds_left) * 3, len(inds_right) * 3))
239 |
240 | # Loop over the atoms on the left side
241 |
242 | print ('\nNow start the loop and move the atoms to calculate the force constant!!!')
243 | for i1 in range(0, len(inds_left)):
244 | # (For test) for i1 in range(0,10):
245 | # Index of the atom on the left
246 | ind1 = inds_left[i1]
247 | # Find the indices of atom ind1 in the 1D array (For test)
248 | indx = 3 * ind1 # directions x
249 | indy = 3 * ind1 + 1 # directions y
250 | indz = 3 * ind1 + 2 # directions z
251 |
252 | print "\tMoving atom %i/%i." % (i1 + 1, len(inds_left))
253 |
254 | # Move atom to directions x(0), y(1), and z(2)
255 |
256 | for direction in [0, 1, 2]:
257 | # Index of the displaced degree of freedom
258 | index = 3 * ind1 + direction
259 | # Get the coordinates from LAMMPS
260 | yc = lmp.gather_atoms("x", 1, 3)
261 | # Move the atom
262 | yc[index] += hstep
263 | # Communicate to LAMMPS
264 | lmp.scatter_atoms("x", 1, 3, yc)
265 | # Run LAMMPS to update the forces
266 | lmp.command("run 0 post no") ## The 'post no' means the full timing summary is skipped; only a one-line summary timing is printed
267 | # Gather the forces
268 | fc1 = lmp.gather_atoms("f", 1, 3) ## The force (including x, y, z) on all the atoms in the interface group
269 | # print "1=",fc1[0]
270 | # print type(fc1)
271 | fc1 = np.array(fc1, dtype=np.dtype('f8'))
272 | # print "2=",fc1[0]
273 | # print fc1[index] ## Print the force of the current atom (if you need to check)
274 | # Move to negative direction
275 | yc[index] -= 2 * hstep
276 | lmp.scatter_atoms("x", 1, 3, yc)
277 | lmp.command("run 0 post no")
278 | fc2 = lmp.gather_atoms("f", 1, 3)
279 | fc2 = np.array(fc2, dtype=np.dtype('f8'))
280 |
281 | # print fc2[index] ## Print the force (negative direction) of the current atom (if you need to check)
282 | # Fill one row of spring constant matrix
283 |
284 | '''
285 | Calculate the force on all atoms in
286 | the right group due to the current atom's displacement (on the left)
287 | '''
288 |
289 | Kij[3 * i1 + direction, :] = (fc2[inds_right_1d] - fc1[inds_right_1d]) / (2.0 * hstep) ## fc2 - fc1 (Yes) ---- (Negative-Positive)
290 | yc[index] += hstep
291 | lmp.scatter_atoms("x", 1, 3, yc) ## Back to equilibrium.
292 |
293 | self.Kij = Kij
294 | lmp.close()
295 |
296 | def writeToFile(self):
297 | '''
298 | Write `self.Kij` to files starting with `self.fileprefix`.
299 | :return: None
300 | '''
301 | np.save(self.fileprefix + '.Kij.npy', self.Kij)
302 | np.save(self.fileprefix + '.ids_L.npy', self.ids_L)
303 | np.save(self.fileprefix + '.ids_R.npy', self.ids_R)
304 | np.save(self.fileprefix + '.ids_Interface.npy', self.inds_interface)
305 | np.savetxt(self.fileprefix, self.Kij, delimiter=' ')
306 | print('\nKij have been written to the ' + self.fileprefix + ' file\n')
307 |
308 |
309 | if __name__ == "__main__":
310 |
311 | # import argparse
312 | # parser=argparse.ArgumentParser()
313 | # parser.add_argument("filePrefix",help="The prefix of file for which to calculate the force constants")
314 | # parser.add_argument("hstep",default=0.01,help="The displacement used in the finite-difference evaluation of force constants.")
315 |
316 | # args=parser.parse_args()
317 | # fileprefix=args.filePrefix
318 | # hstep=args.hstep
319 |
320 | fileprefix = 'Fij.dat'
321 | hstep = 0.01 ## Maybe hstep = 0.01 is a good choice
322 | in_file = 'forces.in' ## The in file for lammps
323 |
324 | with fcCalc(fileprefix) as fc:
325 | fc.preparelammps(in_lammps = in_file, w_interface = 6.0)
326 | fc.fcCalc(hstep)
327 | fc.writeToFile()
328 | print('Forces Calculate All Done\n')
329 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import find_packages, setup, Command
2 | import stat
3 | import os
4 | from shutil import rmtree
5 | import sys
6 |
7 | # Package meta-data.
8 | NAME = 'sdhc'
9 | DESCRIPTION = 'Tools for computing spectral heat current distribution using LAMMPS NEMD simulations'
10 | URL = 'https://github.com/Tingliangstu/Spectral-decomposition-python-tools'
11 | EMAIL = 'ksaaskil@gmail.com and liangting.zj@gmail.com'
12 | AUTHOR = 'Kimmo S\"a\"askilahti and modify by Liang Ting'
13 | REQUIRES_PYTHON = '>=2.7.8'
14 | SRC_DIR = 'sdhc' # Relative location wrt setup.py
15 |
16 | # Required packages.
17 | REQUIRED = ['numpy']
18 |
19 | DEV = ['pytest', 'sphinx', 'sphinx_rtd_theme']
20 |
21 | EXTRAS = {'dev': DEV }
22 |
23 | # Entry point for CLI (relative to setup.py)
24 | ENTRY_POINTS = ['sdhc = sdhc.__main__:main']
25 |
26 | here = os.path.abspath(os.path.dirname(__file__))
27 |
28 | # Import the README and use it as the long-description.
29 | with open(os.path.join(here, 'README.md')) as f:
30 | long_description = '\n' + f.read()
31 |
32 | # Load the package's __version__.py module as a dictionary.
33 | about = dict()
34 | with open(os.path.join(here, SRC_DIR, '__version__.py')) as f:
35 | exec(f.read(), about)
36 |
37 | class SetupCommand(Command):
38 | """Base class for setup.py commands with no arguments"""
39 | user_options = []
40 |
41 | def initialize_options(self):
42 | pass
43 |
44 | def finalize_options(self):
45 | pass
46 |
47 | @staticmethod
48 | def status(s):
49 | """Prints things in bold."""
50 | print('\033[1m{0}\033[0m'.format(s))
51 |
52 | def rmdir_if_exists(self, directory):
53 | self.status("Deleting {}".format(directory))
54 | rmtree(directory, ignore_errors=True)
55 |
56 |
57 | class BuildDistCommand(SetupCommand):
58 | """Support setup.py upload."""
59 | description = "Build the package."
60 |
61 | def run(self):
62 |
63 | self.status("Removing previous builds...")
64 | self.rmdir_if_exists(os.path.join(here, 'dist'))
65 |
66 | self.status("Building Source and Wheel (universal) distribution...")
67 | os.system("{executable} setup.py sdist bdist_wheel --universal".format(executable=sys.executable))
68 | sys.exit()
69 |
70 |
71 | def build_docs():
72 | os.chdir("docs")
73 | os.system("sphinx-apidoc -f -e -o source/ ../sdhc/")
74 | os.system("sphinx-build -M html -D version={version} source build".format(version=about['__version__']))
75 |
76 |
77 | class BuildDocumentationCommand(SetupCommand):
78 | """Builds the sphinx documentation"""
79 | description = "Builds the sphinx documentation."
80 |
81 | def run(self):
82 | self.status("Removing previous builds...")
83 |
84 | build_dir = os.path.join(here, 'docs/build')
85 | self.rmdir_if_exists(build_dir)
86 |
87 | version_dir = os.path.join(here, 'docs', 'version={version}'.format(version=about['__version__']))
88 | self.rmdir_if_exists(version_dir) # Need to delete this before building HTML docs
89 |
90 | self.status("Building documentation...")
91 | build_docs()
92 |
93 | self.status("Docs were built to `docs/build`.")
94 | sys.exit()
95 |
96 |
97 | class TestCommand(SetupCommand):
98 | """Support setup.py test."""
99 | description = "Run local test if they exist"
100 |
101 | def run(self):
102 | os.system("pytest")
103 | sys.exit()
104 |
105 |
106 | setup(
107 | name=NAME,
108 | version=about['__version__'],
109 | description=DESCRIPTION,
110 | long_description=long_description,
111 | long_description_content_type='text/markdown',
112 | author=AUTHOR,
113 | author_email=EMAIL,
114 | python_requires=REQUIRES_PYTHON,
115 | url=URL,
116 | packages=find_packages(exclude=('tests',)),
117 | install_requires=REQUIRED,
118 | extras_require=EXTRAS,
119 | include_package_data=True,
120 | license='Apache 2.0',
121 | classifiers=[
122 | 'Development Status :: 2 - Pre-Alpha',
123 | 'License :: OSI Approved :: Apache Software License',
124 | 'Programming Language :: Python',
125 | 'Programming Language :: Python :: 2.7',
126 | 'Programming Language :: Python :: 3',
127 | 'Programming Language :: Python :: 3.6',
128 | 'Programming Language :: Python :: 3.7',
129 | 'Operating System :: MacOS',
130 | 'Operating System :: POSIX',
131 | 'Operating System :: Unix'
132 | ],
133 | entry_points={'console_scripts': ENTRY_POINTS},
134 | cmdclass={'dist': BuildDistCommand,
135 | 'test': TestCommand,
136 | 'doc': BuildDocumentationCommand}
137 | )
--------------------------------------------------------------------------------