Abstract Phase transitions of metals in hydrogen environments are critically important for applications in energy storage, catalysis, and sensing. Nanostructured metallic particles can lead to faster charging and discharging kinetics, increased lifespan, and enhanced catalytic activities. However, establishing a direct causal link between nanoparticle structure and function remains challenging. In this work, we establish a computational framework to explore the atomic configuration of a metal-hydrogen (M-H) system when in equilibrium with a H environment. This approach combines Diffusive Molecular Dynamics with an iteration strategy, aiming to minimize the system's free energy and ensure uniform chemical potential across the system that matches that of the H environment. Applying this framework, we investigate H chemical potential-composition isotherms during the hydrogenation and dehydrogenation of palladium nanoparticles, ranging in size from $3.9$ nm to $15.6$ nm and featuring various shapes including cube, rhombic dodecahedron, octahedron, and sphere. Our findings reveal an abrupt phase transformation in all examined particles during both H loading and unloading processes, accompanied by a distinct hysteresis gap between absorption and desorption chemical potentials. Notably, as particle size increases, absorption chemical potential rises while desorption chemical potential declines, consequently widening the hysteresis gap across all shapes. Regarding shape effects, we observe that, at a given size, cubic particles exhibit the lowest absorption chemical potentials during H loading, whereas octahedral particles demonstrate the highest. Moreover, octahedral particles also exhibit the highest desorption chemical potentials during H unloading. These size and shape effects are elucidated by statistics of atomic volumetric strains resulting from specific facet orientations and inhomogeneous H distributions. Prior to phase transformation in absorption, a H-rich surface shell induces lattice expansion in the H-poor core, while before phase transformation in desorption, surface stress promotes lattice compression in the H-rich core. The magnitude of the volumetric strains correlates well with the size and shape dependence, underlining their pivotal role in the observed phenomena.