Molecular models of polycrystalline and porous materials