How to calculate the amount of absorbed gas

Dear Lammps expert,
Currently, I build MD simulations of carbon dioxide adsorption on organic matters.
In the simulations, I am confused that how can I get the amount of gas absorbed on the absorbent surface!
To reach the goal should I using some specific Lammps commands or other methods?I don’t find any examples like that.
If you have the some good methods or experiencec, could you please tell me, thank you very much! :smiling_face_with_tear: :smiling_face_with_tear: :smiling_face_with_tear:

First of all, this is a topic that you best discuss and get counseling on from your adviser or tutor or senior, more experienced colleagues, since it is - after all - not really a LAMMPS question, but a simulation analysis question.

Second, your question is a rather specific one, so you are not likely to find a simple “do this, not that” kind of step by step description of what to do, let alone a read-to-use-just-print-this kind of tool that will give you a complete answer. You will have to work for it.

So here are some general suggestions, that can also be applied to other problems if you just translate the questions accordingly. You have to begin with the question: what characterizes the molecules/atoms you are looking for? Or more specifically: what is different between CO2 molecules in the gas phase and when they absorbed?

The first two things that come to my mind are:

  1. atoms/molecules in the gas phase move faster and get displaced a longer distance over time, absorbed atoms/molecules will be retarded and thus move slower and won’t get much displaced. This would be even more true for the center of mass of a molecule than individual atoms. With (rigid) CO2 you could thus look at the carbon atoms only, since they will also be the center of mass.
  2. atoms/molecules in the gas phase have a low density, while the density where atoms get absorbed will be high (or higher).

So how to quantify this?

  1. You can look at the velocity and try to find a threshold value for your system, where the velocity above would signify gas phase and below would indicate absorption. …and if you work about “local” vibrations, you could look at time averaged velocities. This threshold could be found empirically through visualization. Then for quantification, you can then program this in LAMMPS with an atom style variable, that computes the total velocity of the carbon atoms either directly from sqrt(vx**2+vy**2+vz**2) or from time averaged data processing those velocity components with fix ave/atom. In an atom style variable, you can use an expression like (sqrt(vx**2+vy**2+vz**2) < v_vthresh) * (type == 1) with vthresh being an index or equal style variable that holds the empirically determined threshold and the 1 being that atom type of the CO2 carbon atoms. This expression will be 1 only for slower carbon atoms and 0 for all others. Use compute reduce sum on that atom style variable and you have a count.
  2. You can create a 1-d density profile of the CO2 carbon atoms using compute chunk/atom bin1d and then compute reduce/chunk sum to compute the total mass per bin. Plotting that 1-d mass profile should (if divided by the volume of each chunk you can also get the density) should provide you with an indicator for which chunks are absorbed and which are gas, i.e. when the density goes below a certain (empirical) threshold. If you divide by the carbon mass, you would get the count of absorbed atoms.

If you want to get real fancy, you could consider a combination of both quantification approaches.

I hope this will put you on the right path.


Thank you very much for your pertinent advice and help. I am researching in the area of CO2 geological storage and I am the first PhD in my group to do molecular dynamics research. Neither my supervisor nor my classmates have done any research in this area, so I can only discuss with other PhDs , teachers and lammps users online to take their experiences and suggestions.

Regarding your advice on adsorption calculation, I will combine it well with related theories and lammps commands, and I would like to sincerely thank you for your answers to my questions and sincere help.
I wish you good health and all the best. :heart: :heart: :heart:

I have heard and read this explanation and justification many times and it is not valid. I consider it not a smart idea (from both, you and your supervisor) to start research in a completely new area without having some in-person expertise at hand that can provide guidance and tutoring. That will run an extremely high risk of making trivial mistakes that would not happen to experienced researchers. Online forums and tutorials can help, but are no substitute. There is much more to running correct MD simulations than having something that will work run without errors. Thus if you don’t have the expertise at hand within your group, you (or rather your supervisor) need to reach out and find a sufficiently experienced collaborator (or more) and work with them and receive tutoring and advice from them. MD is much more a craft than a science and there are lots of things that are not written down, but still matter that you can really only learn from practicing along experienced people. Keep in mind that you are dealing with 50-60 years of combined experience of the entire research community that did/does MD. There is a lot of residual practical knowledge out there.


I have survived being The Lone Computationalist, and based on my experience, it is a terrible place to be. Long story short, you are at severe risk of achieving very little in your PhD unless your supervisor finds a collaborator with substantial MD experience who is willing to co-supervise you and co-author with your supervisor (and whom your supervisor is willing to co-author with).

This sort of situation would not be accepted in any other field of science. No supervisor (I hope!) would expect a PhD student with zero experience to run experiments with a microscope, fume hood, HPLC column, or laser table, without arranging prior training and follow-up mentoring from a lab tech or postdoc. And yet this is how students are often asked to approach MD. Maybe supervisors don’t feel they’ve lost anything because they don’t have to pay anything for LAMMPS or other packages. But they’ll have wasted a student and the student is left with much worse prospects after graduation. (There is even the physiological and psychological harm of sitting all day at a computer to account for – small, but not zero.)

To make this tangible: what will you do when you approach your supervisor, present your results, and find that you can’t line them up with experimental data? You will have to decide which of the following has happened:

  1. You did something wrong and need to start over.
  2. You did nothing wrong but you need to run longer to equilibrate your system and get good statistics.
  3. You did nothing wrong but it is not physically possible to run long enough to get good statistics.
  4. You did nothing wrong and your results are qualitatively correct – the real-life system is too complicated to get quantitative agreement.
  5. You did nothing wrong, the experimental papers are wrong.

I have personally experienced or seen all of the above. Deciding which of the above has happened, and either correcting it or arguing for it in a peer-reviewed journal article, is work worthy of a co-authorship and certainly requiring scrutiny during peer review. When a reviewer says you’ve used the wrong thermostat and the wrong short-range cutoff, you won’t be able to reply “But someone on the Internet said it was okay!” You need more guidance than that.

To be very clear, I have no doubt that you have the intelligence and perseverance that is needed to complete your PhD. But you do need the guidance of a dedicated supervisor or mentor, just the same as in any other field of research. And if your supervisor can’t find you that level of help (at least for your first paper) then your publication record, future career, and overall scientific effectiveness is being put in severe risk.

POST-EDIT: Here’s an easy and practical step to take: Reach out to the administrators of your local supercomputing cluster, and ask them which of their MD users might have the capacity to co-supervise your PhD or co-author your first paper. (You won’t be able to complete your PhD without relying on a cluster.)


Thank you very much for your valuable comments.
After I communicated with my boss, he introduced a professor in MD simulation research to guide me with theoretical and technical problems I encountered during my research. I deeply appreciate your advice and concern.
Wish you all the best. :smiling_face_with_three_hearts:


I highly appreciate your wonderful comments that are so much helpful