How to calculate molarity and the number of molecules for a mixture in a simulation box?

I want to do a simulation of a mixture which consists a total of $512$ molecules of glycine, ammonia, and water molecules mixture in a cubic box of, say, length $\pu{2.6 nm}$; $\pu{2.6 nm}^3 = \pu{17.576 nm3}$ in terms of volume.


I want [1 glycine molecule + $x$ ammonia molecules + $y$ water molecules] which together comes to a total of $512$ molecules and in a box volume of $\pu{17.576 nm3}$ and molarity should be $\pu{15 M}$. 


Actually here I am fixing the glycine molecule which is only one and varying only the number of ammonia and water molecules to get different molar concentrations, say, $\pu{5 M / 10 M / 15 M}$ and $\pu{18 M}$, where the total number of molecules is constant, i.e. $512$ molecules only (see the example below). Since a maximum of $\pu{18 M}$ solution can be prepared (since ammonia solubility is $\pu{31 g}$ in $\pu{100 mL}$), so, I am trying to study with varying the $\%$ composition of ammonia and water molecules.


In this case I want to get a concentration of $\pu{15 M}$.
How to calculate the number of $x$ ammonia and $y$ water molecules that need to be taken in order to get $\pu{15 M}$, considering the conversion of number of molecules to mass, amount of substance, etc..


For example:


* $1$ molecule of glycine + $52$ molecules of ammonia + $459$ molecules of water is $10 : 90$ mixture (total $512$ molecules);
* $1$ molecule of glycine + $104$ molecules of ammonia + $408$ molecules of water is $20 : 80$ mixture (total $512$ molecules).


Then what would be the molarity of the above two mixtures ($1 : 90$, $20 : 80$) considering the same volume ($\pu{17.576 nm}$)?




I would use a slightly different approach than andselisk, based on the volume on your box, and that I don't think you can neglect the volume of your ammonia molecules. Given $V(\text{sol}) = \pu{17.576E-27 m3}$ and $c(\ce{NH3}) = \pu{15.0E3 mol m-3}$ we can calculate the number of ammonia molecules we need:
\begin{align}
 && c(\ce{NH3}) &= \frac{n(\ce{NH3})}{V(\text{sol})};\\
 && n(\ce{NH3}) &= \frac{N(\ce{NH3})}{N\_\mathrm{A}};\\
&\to&
 c(\ce{NH3}) &= \frac{N(\ce{NH3})}{N\_\mathrm{A}\cdot V(\text{sol})}\\
&\Longleftrightarrow&
 N(\ce{NH3}) &= c(\ce{NH3})\cdot N\_\mathrm{A}\cdot V(\text{sol}) \approx 159
\end{align}


Since you want to limit the number of molecules to $512$, we know that all other molecules have to be water:
$$N(\ce{H2O}) = 512 - N(\ce{Gly}) - N(\ce{NH3}) = 352$$


Lastly, let's check whether the density is anywhere close to what we would expect, we take $M\_\mathrm{m}(\ce{Gly}) = \pu{75 u}$, $M\_\mathrm{m}(\ce{H2O}) = \pu{18 u}$, and $M\_\mathrm{m}(\ce{NH3})= \pu{17 u}$.
\begin{align}
 \rho(\text{sol}) &= \frac{m(\text{sol})}{V(\text{sol})}\\
 &= \frac{\left(
 N(\ce{Gly})M\_\mathrm{m}(\ce{Gly}) 
 + N(\ce{H2O})M\_\mathrm{m}(\ce{H2O})
 + N(\ce{NH3})M\_\mathrm{m}(\ce{NH3})\right)\frac{m\_\mathrm{u}}{\pu{u}}
 }{V(\text{sol})}\\
 \rho(\text{sol}) &\approx \pu{861 kg m-3} = \pu{0.861 g cm-3}
\end{align}


Citing [Wikipedia's entry of ammonia](https://en.wikipedia.org/wiki/Ammonia#Properties) I would say you are quite close:



> 
> **Solvent properties**  
> 
>  Ammonia is miscible with water. [...] The maximum concentration of ammonia in water (a saturated solution) has a density of $\pu{0.880 g cm-3}$ and is often known as '.880 ammonia'. [...]
> 
> 
> 


The Handbook of Chemistry and Physics has a concentration table (91st Edition p. 8-53; currently [98th Edition](https://www.crcpress.com/CRC-Handbook-of-Chemistry-and-Physics-98th-Edition/Rumble/p/book/9781498784542), also [online](http://hbcponline.com)), and I'll reproduce a couple of values for comparison, at $\pu{20 ^\circ C}$.


\begin{array}{rrr}
 \text{Mass\%} & c / \pu{mol L-1} & \rho / \pu{g cm-3}\\\hline
 5.0 & 2.868 & 0.9770\\
 9.0 & 5.080 & 0.9613\\
 12.0 & 6.695 & 0.9502\\
 18.0 & 9.823 & 0.9294\\
 24.0 & 12.826 & 0.9102\\
 28.0 & 14.764 & 0.8920\\\hline
\end{array}


In conclusion, you are a few water molecules short, or your box is slightly too large, or your solution is not dense enough. I would expect some trade-offs when doing such a study and keeping the named constraints, so I guess you should have a close look at everything and settle for the optimum you can afford.


 2

Using conventional macroscale quantities and SATP, one can express the desired concentration of aqueous ammonia using the amount $n$ and the volume $V$ of the solution:


$$C(\ce{NH3}) = \frac{n(\ce{NH3})}{V(\ce{H2O})} \tag{1}$$


Let's find the ratio between the numbers of molecules of ammonia ($N(\ce{NH3})$) and water ($N(\ce{H2O})$). By definition of a mole ($N\_\mathrm{A}$ – Avogadro's number):


$$n(\ce{NH3}) = \frac{N(\ce{NH3})}{N\_\mathrm{A}} \tag{2}$$


Volume of water required to achieve given concentration can be found using density $\rho$ and molecular weight $M$:


$$V(\ce{H2O}) = \frac{m(\ce{H2O})}{\rho (\ce{H2O})} = \frac{n(\ce{H2O}) \cdot M(\ce{H2O})}{\rho (\ce{H2O})} = \frac{N(\ce{H2O}) \cdot M(\ce{H2O})}{\rho (\ce{H2O}) \cdot N\_\mathrm{A}} \tag{3}$$


Assembling (2) and (3) in (1):


$$\frac{N(\ce{H2O})}{N(\ce{NH3})} = \frac{\rho (\ce{H2O})}{C(\ce{NH3}) \cdot M(\ce{H2O})} = \frac{\pu{1.0e3 g L-1}}{\pu{15 mol L-1} \cdot \pu{18.015 g mol-1}} = 3.70 \tag{4}$$


Now, knowing the ratio between ammonia and water, total number of molecules in system and assuming that single glycine molecule remains intact, one can count the exact numbers:


$$1 + N(\ce{NH3}) + 3.70 \cdot N(\ce{NH3}) = 512$$
$$\to N(\ce{NH3}) \approx 109 $$
$$\to N(\ce{H2O}) \approx 402 $$


By the way, 402 water molecules would only occupy $\pu{1.20e-26 m^3}$ (formula (3)), assuming this molecular assembly (cluster) behaves similarly to its macro counterpart (which is probably not exactly true). This means that you need a slightly smaller cube with a side of about $\sqrt[3]{\pu{1.20e-26 m^3}} = \pu{2.3 nm}$.


The same procedure can be repeated for other concentrations.


 1