# How lammps calculate the mass and density for each bin

Hi lammps-users

I use
compute chunk/atom bin/1d
fix ave/chunk

commands to divide my system to different bins and calculate the density for each bin.The density is calculated by the mass/volume where the volume is the bin volume according to the mamul. My questions is how lammps calculate the mass. The final output just give the Ncount (the number of atoms in each bin) and the density,but it does not show the atom type. For example, I have water moleculers which have H and O atoms, if lammps does not know the atom type, how can it calculate the mass in each bin. If lammps does know about it? How can I output (atom type and mass) with the density?

Fan Li

Atoms or particles in LAMMPS always have a mass, else

LAMMPS cannot time integrate them with a force.

Your script either has a mass command, or the data file sets

it, or an EAM potential files sets it.

Steve

Hi
I do have atom type and mass in my data file.
I want to output the total mass of each bin then calculate the density by hand because there is divergence between lammps reported density and the initial density whic I build. I want to figure out what is wrong. To do it, I need both total number of atoms in each bin and how many atoms in each type (for example, 200 H atoms and 150 O atoms in some bin) . How can know that ?

Fan Li

The compute chunk/atom commands assigns a chunk ID

to each atom, which in your case is the bin #. You can

dump that property with the atom to a dump file, e.g. create

a dump file with only the atoms in bin #1 if you like.

Then you can post-process the dump file however you wish.

Or you could define a dynamic group that is only the atoms

with a certain chunk ID, and use a variable formula to count

the # of atoms in that group and output the value with thermo output.

Steve
{"ft_lang_label":"__label__en","ft_lang_prob":0.9386142,"math_prob":0.8556771,"size":1018,"snap":"2022-40-2023-06","text_gpt3_token_len":235,"char_repetition_ratio":0.1597633,"word_repetition_ratio":0.010256411,"special_character_ratio":0.22495088,"punctuation_ratio":0.08256881,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9868778,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-26T10:07:11Z\",\"WARC-Record-ID\":\"<urn:uuid:01269034-863f-4faa-9fac-398a17db1593>\",\"Content-Length\":\"22918\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3f7d94a8-d49c-4c07-a9c3-486de4676e03>\",\"WARC-Concurrent-To\":\"<urn:uuid:29fbde69-3f35-49fd-a645-4a4564463d8f>\",\"WARC-IP-Address\":\"172.67.203.138\",\"WARC-Target-URI\":\"https://matsci.org/t/how-lammps-calculate-the-mass-and-density-for-each-bin/27423\",\"WARC-Payload-Digest\":\"sha1:WL2IE5R7QA6BDUTSAIYXRJ25AYFBOES3\",\"WARC-Block-Digest\":\"sha1:IG5KSE6T5HC4EBJYQ3L3FB3TKUXW6VPI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030334855.91_warc_CC-MAIN-20220926082131-20220926112131-00324.warc.gz\"}"}