1. XRD may yield the lattice parameters of your crystal.
2. Assuming the composition known, a theoretical density value can be calculated valid for zero porosity.
3. An experimental density value of a real specimen of the crystal can be obtained mby using a pycknometer together with any balance of sufficient accuracy, yielding an experimental density value.
4. The porosity is related to the proportion between the experimental and theoretical density.
If you have determined the crystal structure you can use the program PLATON.
It calculates the porosity by simulating a probe on every position in a regular 3D grid ( with typically 0.2 Å between each grid point) in the unit cell and counts how many times the probe in within the van der Waals radius of any atom, and how many times it falls outside. The ratio between these numbers gives the packing coefficient. PLATON also tells you the positions of the centre of each cavity and the volume of each cavity.
Note that it is common to add 1.2 Å or so to the van der Waals radii, to simulate a radius of the probe itself. PLATON reports volumes both with and without this extra radius.
If you don't have the crystal structure, but only lattice parameters and Z, you can calculate the volume of the unit cell as the triple product of the lattice vectors and the van der Waals volume of the individual molecule you can get from Molinspiration, google it.