0%

Understand the LAMMPS source code and modify it to meet your research needs, and run simulations for bespoke applications involving forces, thermostats, pair potentials and more with ease

Key Features

  • Understand the structure of the LAMMPS source code
  • Implement custom features in the LAMMPS source code to meet your research needs
  • Run example simulations involving forces, thermostats, and pair potentials based on implemented features

Book Description

LAMMPS is one of the most widely used tools for running simulations for research in molecular dynamics. While the tool itself is fairly easy to use, more often than not you'll need to customize it to meet your specific simulation requirements. Extending and Modifying LAMMPS bridges this learning gap and helps you achieve this by writing custom code to add new features to LAMMPS source code. Written by ardent supporters of LAMMPS, this practical guide will enable you to extend the capabilities of LAMMPS with the help of step-by-step explanations of essential concepts, practical examples, and self-assessment questions.

This LAMMPS book provides a hands-on approach to implementing associated methodologies that will get you up and running and productive in no time. You'll begin with a short introduction to the internal mechanisms of LAMMPS, and gradually transition to an overview of the source code along with a tutorial on modifying it. As you advance, you'll understand the structure, syntax, and organization of LAMMPS source code, and be able to write your own source code extensions to LAMMPS that implement features beyond the ones available in standard downloadable versions.

By the end of this book, you'll have learned how to add your own extensions and modifications to the LAMMPS source code that can implement features that suit your simulation requirements.

What you will learn

  • Identify how LAMMPS input script commands are parsed within the source code
  • Understand the architecture of the source code
  • Relate source code elements to simulated quantities
  • Learn how stored quantities are accessed within the source code
  • Explore the mechanisms controlling pair styles, computes, and fixes
  • Modify the source code to implement custom features in LAMMPS

Who this book is for

This book is for students, faculty members, and researchers who are currently using LAMMPS or considering switching to LAMMPS, have a basic knowledge of how to use LAMMPS, and are looking to extend LAMMPS source code for research purposes. This book is not a tutorial on using LAMMPS or writing LAMMPS scripts, and it is assumed that the reader is comfortable with the basic LAMMPS syntax. The book is geared toward users with little to no experience in source code editing. Familiarity with C++ programming is helpful but not necessary.

Table of Contents

  1. Extending and Modifying LAMMPS
  2. Writing Your Own Source Code
  3. Why subscribe?
  4. Foreword
  5. Contributors
  6. About the authors
  7. About the reviewers
  8. Packt is searching for authors like you
  9. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  10. Section 1: Getting Started with LAMMPS
  11. Chapter 1: MD Theory and Simulation Practices
    1. Technical requirements
    2. Introducing MD theory
    3. Understanding the dynamics of point particles
    4. Performing iterative updates using the Velocity Verlet algorithm
    5. Understanding rotational motion
    6. Examining temperature and velocity distribution of particles
    7. Implementing MD simulation practices
    8. Pair-potential cutoff
    9. Periodic boundary conditions
    10. Neighbor lists
    11. Processor communication
    12. Summary
    13. Questions
  12. Chapter 2: LAMMPS Syntax and Source Code Hierarchy
    1. Technical requirements
    2. Introducing the LAMMPS input script structure
    3. Introducing the source code repository
    4. Reviewing the source code hierarchy
    5. Summary
    6. Further reading
    7. Questions
  13. Section 2: Understanding the Source Code Structure
  14. Chapter 3: Source Code Structure and Stages of Execution
    1. Technical requirements
    2. Introducing parent and child classes
    3. fix.cpp and fix.h
    4. pair.cpp and pair.h
    5. compute.cpp and compute.h
    6. Stages of executing the simulation
    7. verlet.cpp
    8. min.cpp
    9. Role of pointers class
    10. Parsing input script commands by input.cpp
    11. Summary
    12. Further reading
    13. Questions
  15. Chapter 4: Accessing Information by Variables, Arrays, and Methods
    1. Technical requirements
    2. Accessing atom properties during simulation runs
    3. Mapping atom indices
    4. Requesting a neighbor list
    5. Accessing physical constants
    6. Reading parameters from the input script
    7. Incorporating new data types
    8. Summary
    9. Questions
  16. Chapter 5: Understanding Pair Styles
    1. Technical requirements
    2. Reviewing the general structure of pair styles
    3. Reviewing the Morse potential
    4. PairMorse::allocate()
    5. PairMorse::settings()
    6. PairMorse::coeff()
    7. PairMorse::init_one()
    8. PairMorse::compute()
    9. PairMorse::single()
    10. Reviewing the table potential
    11. PairTable::settings()
    12. PairTable::coeff()
    13. PairTable::compute()
    14. Reviewing the DPD potential
    15. PairDPD::settings()
    16. PairDPD::compute()
    17. Summary
    18. Questions
  17. Chapter 6: Understanding Computes
    1. Technical requirements
    2. Reviewing the general structure of computes
    3. Reviewing the compute KE class
    4. ComputeKE::ComputeKE()
    5. ComputeKE::init()
    6. ComputeKE::compute_scalar()
    7. Reviewing the compute group/group class
    8. ComputeGroupGroup::ComputeGroupGroup()
    9. ComputeGroupGroup::init() and init_list()
    10. ComputeGroupGroup::pair_contribution()
    11. ComputeGroupGroup::compute_scalar() and compute_vector()
    12. Reviewing the compute RDF class
    13. ComputeRDF::ComputeRDF()
    14. ComputeRDF::init() and init_list()
    15. ComputeRDF::init_norm()
    16. ComputeRDF::compute_array()
    17. Reviewing the compute heat flux class
    18. ComputeHeatFlux::ComputeHeatFlux()
    19. ComputeHeatFlux::init()
    20. ComputeHeatFlux::compute_vector()
    21. Summary
    22. Questions
  18. Chapter 7: Understanding Fixes
    1. Technical requirements
    2. Exploring the general structure of fixes
    3. Reviewing the Fix AddForce class
    4. FixAddForce::FixAddForce()
    5. FixAddForce::init()
    6. FixAddForce::setmask()
    7. FixAddForce::post_force()
    8. Studying the Fix NVE class
    9. FixNVE::initial_integrate()
    10. FixNVE::final_integrate()
    11. Studying the Fix NH class
    12. Studying the Fix Print class
    13. FixPrint::FixPrint()
    14. FixPrint::end_of_step()
    15. Reviewing the Fix Orient/FCC class
    16. FixOrientFCC::FixOrientFCC()
    17. FixOrientFCC::find_best_ref()
    18. FixOrientFCC::post_force()
    19. Analyzing the Fix Wall and Fix Wall/LJ126 classes
    20. Fix wall/lj126
    21. Exploring the Fix Rigid class
    22. FixRigid::initial_integrate()
    23. FixRigid::set_xv()
    24. FixRigid::final_integrate()
    25. Summary
    26. Questions
  19. Chapter 8: Exploring Supporting Classes
    1. Technical requirements
    2. Discovering the Group class
    3. Exploring the Variable class
    4. Studying the Error class
    5. Error::all()
    6. Error::one()
    7. Error::warning() and message()
    8. Reviewing the Memory class
    9. Discussing the Angle and angle/harmonic classes
    10. The Angle class
    11. The angle/harmonic class
    12. Summary
    13. Questions
  20. Section 3: Modifying the Source Code
  21. Chapter 9: Modifying Pair Potentials
    1. Technical requirements
    2. Writing a harmonic potential
    3. Changing class names
    4. Changing variables and equations
    5. Parsing input parameters for Pair Harmonic
    6. Trial run (in.Test_PairHarmonic)
    7. Writing a height-dependent pair potential
    8. Changing the header file, pair_table.h
    9. Parsing input parameters for Pair TableZ
    10. Implementing height-dependence
    11. Trial run (in.Test_PairTableZ)
    12. Writing a friction-based pair style
    13. Modifying the compute() method
    14. Trial run (in.Test_PairCundallStrack)
    15. Summary
    16. Questions
  22. Chapter 10: Modifying Force Applications
    1. Technical requirements
    2. Writing a fix to apply a 2D spring force
    3. Theory (2D spring force)
    4. Modifying the header file – addforceXY.h
    5. Modifying the constructor in fix_addforceXY.cpp
    6. Modifying the init() method in fix_addforceXY.cpp
    7. Modifying the post_force() method in fix_addforceXY.cpp
    8. Trial run (in.Test_FixAddforceXY)
    9. Writing a fix to apply an active force
    10. Theory (active force on bonded atoms)
    11. Modifying the header file – fix_activeforce.h
    12. Modifying the constructor in fix_activeforce.cpp
    13. Modifying the post_force() method in fix_activeforce.cpp
    14. Trial run (in.Test_ActiveForce)
    15. Writing a fix to apply a custom wall force
    16. Theory (expanded Lennard–Jones wall force)
    17. Modifying the header file
    18. Modifying the constructor in fix_wall_region.cpp
    19. Modifying the init() method in fix_wall_region.cpp
    20. Adding the lj126Expanded() method
    21. Modifying the post_force() method
    22. Trial run (in.Test_WallRegion)
    23. Writing a fix to apply a bond-boost potential
    24. Theory (the bond-boost method)
    25. Modifying the header file – fix_addboost.h
    26. Modifying the constructor in fix_addboost.cpp
    27. Modifying the init() method in fix_addboost.cpp
    28. Modifying the post_force() method in fix_addboost.cpp
    29. Trial run (in.Test_FixAddboost)
    30. Summary
    31. Questions
  23. Chapter 11: Modifying Thermostats
    1. Technical requirements
    2. Writing a fix to apply the Andersen thermostat
    3. Theory – Andersen thermostat
    4. Modifying the header file – fix_temp_andersen.h
    5. Modifying the constructor in fix_temp_andersen.cpp
    6. Modifying the end_of_step() method of fix_temp_andersen.cpp
    7. Trial run – in.Test_Andersen
    8. Writing a fix to apply a non-linear temperature increment
    9. Theory – Exponential temperature increment
    10. Modifying the fix_nh.h header file
    11. Modifying the constructor in fix_nh.cpp
    12. Modifying the init() method in fix_nh.cpp
    13. Modifying the compute_temp_target() method in fix_nh.cpp
    14. Modifying the compute_scalar() method in fix_nh.cpp
    15. Trial run – in.Test_Addboost
    16. Writing a fix to print output at evaporation
    17. Theory – Evaporation region
    18. Modifying the header file – fix_printEvaporate.h
    19. Modifying the constructor and init() methods in fix_printEvaporate.cpp
    20. Modifying the end_of_step() method in fix_printEvaporate.cpp
    21. Trial run – in.Test_PrintEvaporate
    22. Summary
    23. Questions
  24. Appendix A: Building LAMMPS with CMake
    1. Technical requirements
    2. Prerequisites for working with LAMMPS
    3. Downloading the source code
    4. Installing the dependencies
    5. Downloading MPICH
    6. Building LAMMPS
    7. Including packages in the build
    8. Including modified codes
    9. Building with CMake
    10. Compiling LAMMPS in Windows
    11. Downloading Git for Windows
    12. Downloading the source code
    13. Downloading CMake for Windows
    14. Downloading Microsoft MPI
    15. Downloading Code::Blocks
    16. Developing LAMMPS
    17. Building with Make
    18. Further reading
  25. Appendix B: Debugging Programs
    1. Technical requirements
    2. What is debugging?
    3. Prerequisites
    4. Method 1 – Debugging with GDB
    5. Method 2 – Debugging with VSCode
    6. Insight into sbmask()
    7. Further reading
  26. Appendix C: Getting Familiar with MPI
    1. Technical requirements
    2. What is MPI?
    3. MPI initialization
    4. MPI finalization
    5. MPI current process ID
    6. MPI (number of processes)
    7. MPI send message
    8. MPI receive message
    9. MPI message
    10. MPI in LAMMPS
    11. Example of evaluating
    12. Data exchange between owned atoms and ghost atoms
  27. Appendix D: Compatibility with Version 29Oct20
    1. Technical requirements
    2. Translating Fix Widom into the 3Mar20 version
    3. Incompatibility 1 – Parsing input parameters
    4. Incompatibility 2 – Atom class
    5. Incompatibility 3 – Function signatures in group.cpp
  28. Assessments
    1. Chapter 1, MD Theory and Simulation Practices
    2. Question 1
    3. Answer
    4. Question 2
    5. Answer
    6. Question 3
    7. Answer
    8. Question 4
    9. Answer
    10. Chapter 2, LAMMPS Syntax and Source Code Repository
    11. Question 1
    12. Answer
    13. Question 2
    14. Answer
    15. Chapter 3, Source Code Structure and Stages of Execution
    16. Question 1
    17. Answer
    18. Question 2
    19. Answer
    20. Question 3
    21. Answer
    22. Chapter 4, Accessing Information by Variables, Arrays, and Methods
    23. Question 1
    24. Answer
    25. Question 2
    26. Answer
    27. Question 3
    28. Answer
    29. Chapter 5, Understanding Pair Styles
    30. Question 1
    31. Answer
    32. Question 2
    33. Answer
    34. Question 3
    35. Answer
    36. Question 4
    37. Answer
    38. Chapter 6, Understanding Computes
    39. Question 1
    40. Answer
    41. Question 2
    42. Answer
    43. Question 3
    44. Answer
    45. Question 4
    46. Answer
    47. Chapter 7, Understanding Fixes
    48. Question 1
    49. Answer
    50. Question 2
    51. Answer
    52. Question 3
    53. Answer
    54. Chapter 8, Exploring Supporting Classes
    55. Question 1
    56. Answer
    57. Question 2
    58. Answer
    59. Question 3
    60. Answer
    61. Chapter 9, Modifying Pair Potentials
    62. Question 1
    63. Answer
    64. Question 2
    65. Answer
    66. Question 3
    67. Answer
    68. Chapter 10, Modifying Force Applications
    69. Question 1
    70. Answer
    71. Question 2
    72. Answer
    73. Question 3
    74. Answer
    75. Chapter 11, Modifying Thermostats
    76. Question 1
    77. Answer
    78. Question 2
    79. Answer
  29. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
18.219.22.169