# Perodic boundary conditions vs Dirichlet?

I have been working through several examples recently involving particles in boxes (when finding the partition function of an ideal gas for example or looking at photon gases). I have seen two approaches:

Approach 1

Take the wave function: $$\psi=A\sin\left(k_x x\right)\sin\left(k_y y\right)\sin\left(k_z z\right)$$ And the associated boundary condition that the wavefunction must vanish at the walls. Given us: $$\psi=A\sin\left(\frac{\pi n_x}{L_x}x\right)\sin\left(\frac{\pi n_y}{L_y}y\right)\sin\left(\frac{\pi n_z}{L_z}z\right)$$

Approach 2

Take the wavefunction: $$\psi=Ae^{ik_x x}e^{ik_y y}e^{i k_z z}$$ And the associated boundary condition that the wavefunction is periodic at the walls. Given us: $$\psi=A e^{i\frac{2\pi}{L_x} n_x x}e^{i \frac{2 \pi}{L_y} n_y y}e^{i \frac{2\pi}{L_z} n_z z}$$

These two approaches seem to both work in the applications I have given above (partition function of ideal gas and photon gas). Please can someone explain why this is since only the first approach is actually represents the situation at hand?

• Vanishing at the walls is a special case of periodic at the walls; justcset the constant phase to zero at the end. – Peter Diehr Feb 27 '16 at 12:37