Density of states and boundary conditions: how the density of states is physical if it depends on box size This question is closely related to this one: Why is the density of states required conceptually? Should it be seen as a mathematical trick related to Fourier series?
But it was suggested that I ask this question separately.
My question is about the motivation of defining density of states, and its relationship with the boundary conditions when starting from a discrete situation.
I take a simple example: free propagating waves in 1D, thus a solution of the equation:
$$\partial_x^2 f - \frac{1}{c^2} \partial_t^2 f=0$$
I want to find the density of states and then compute the average energy at temperature $T$ that those waves are containing.
If I want to start from a discretized scenario before going to the continuum, I first have to choose boundary conditions on a "box size" $L$.
Periodic boundary choice:
I allow my waves to verify $f(x+L,t)=f(x,t)$. The wavevectors describing those waves are:
$$k_n=\frac{2 n \pi}{L}, n \in \mathbb{Z}$$
$$\langle E \rangle = 2\sum_{n \geq 0} \hbar \omega_n n_B(\omega_n)$$
Where $\omega_n = c |k_n|$, and $n_B(\omega_n)$ the boson population at frequency $\omega_n$ (and at temperature $T$). The factor "2" is here because of the forward and backward propagating waves. Also, the "gap" between two consecutives frequencies is $\delta \omega_n=2c \frac{\pi}{L}$. Using this remark I will be able to find the continuum limit of this summation. I have:
The factor $2$ is here because of the two directions of propagation. Now, if I want to "go to the continuum", I use the fact that: $E_n = \hbar \omega_n$, and:
$$\sum_{n \geq 0} f_n =\sum_{n \geq 0} f_n \frac{\delta E_n}{\delta E_n}=\frac{L}{2 \pi \hbar c}\sum_{n \geq 0} f_n \delta E_n$$
Thus, I have, for $L \gg 1$
$$ \langle E \rangle \approx \int_0^{+\infty} d E (2*\frac{L}{2 \hbar \pi c}) E \ n_B(E) =  \frac{L}{\hbar \pi c}  \int_0^{+\infty} d E \ E \ n_B(E)$$
It gives me the density of states: $\rho_L(E)=\frac{L}{ \hbar \pi c}$
My questions

*

*How can the density of state be physical as it depends on a fictive length $L$
If you agree with what I wrote, and if the density of states is something physical, I don't understand how it can be here. Indeed it explicitely depends on the fictive length $L$, it cannot be physical because of that. Now, as suggested in some of the answers, in the end of the calculation one has to take $L \to + \infty$. In this case the density of states would diverge. How to make sense of this quantity then ? Is it that we reason with the density of state "per" unit length (which does not diverge). Also, in this example it works, but are we sure that "in general", for more complicated scenarios, the density of state per unit volume would become independent of the box size that has been choosen ?

*

*How to avoid this "trick" of using periodic boundary condition in order to find $\langle E \rangle$
As suggested by some of the answers of the linked post, I could directly work in the continuum by considering delta distribution to define the density of states. It should in the end give the same result. I have no idea of how to proceed to find the same result directly working with the continuum and I am interested to see how the two approaches match. I guess that some "dirac distribution" in the limit $L \to +\infty$ in my calculation but I really don't see how.

*

*Does the choice of boundary conditions matter for the density of states ?

I tried to impose strict boundary conditions, i.e: $f(0,t)=f(L,t)=0$ which gives stationnary modes. The meaning of the modes differ but in the end of the calculation, I found the same density of states and average energy. Is it exactly what is meant by those topics Why are periodic boundary conditions used for the derivation of phonons? Why are periodic boundary conditions used for the derivation of phonons?
The predictions I will make are independent of the boundary condition I will choose ? Is there a nice reference in which this thing is precisely discussed ? In all book that I found they just apply periodic boundary condition without any real justification for that.
 A: First, it's important to clarify that very often $L$ is not fictional.  In condensed matter systems, $L$ is genuinely the size of the system.  However, if you're working with a crystal on the scale of millimeters or centimeters in size, this is immense compared to the atomic scale, justifying the use of the $L\rightarrow \infty$ limit.

How can the density of state be physical as it depends on a fictive length $L$?

$\rho(E) \mathrm dE$ is the number of states per unit volume of the system which exist in the range $[E, E+\mathrm dE]$.  More generally, if you have some energy range $R$, then the total number of states in that energy range is given by
$$N(R) = V\int_R \rho(E) \mathrm dE$$
If you have a set of non-degenerate, discrete energy levels (as you do for a particle in a 1D box, for instance), the density of states is formally a sum of delta functions:
$$\rho_L(E) = \frac{1}{L}\sum_{n=1}^\infty \delta\left(E- \frac{n^2 \pi^2 \hbar^2}{2mL^2}\right)$$
which, as you say, explicitly depends on $L$. However, consider what happens when we integrate some function $f(E)$ against $\rho_L$:
$$\int f(E) \rho_L(E) \mathrm dE = \sum_{n=1}^\infty f(E_n) \cdot \frac{1}{L}$$
Note that $\Delta E_n \equiv E_{n+1}-E_n = \frac{(2n+1)\pi^2 \hbar^2}{2mL^2}= \frac{2n+1}{n^2} E_n$, so $\frac{\Delta E_n}{E_n}=\frac{2}{n} + \frac{1}{n^2}$.  Furthermore, $n = \sqrt{\frac{2mL^2 E}{\pi^2\hbar^2}}$, so we have
$$\frac{\Delta E_n}{E_n} = \frac{2\pi \hbar}{L\sqrt{2mE_n}} + \frac{2\pi^2 \hbar^2}{mL^2 E_n} \rightarrow \frac{\pi \hbar}{L}\sqrt{\frac{2}{mE_n}}$$
in the limit of large $N$.  This can be rearranged to yield
$$\frac{1}{L} =\sqrt{\frac{m}{2\pi^2\hbar^2 E_n}} \Delta E_n$$
which means that our original integral becomes
$$\int f(E) \rho_L(E) \mathrm dE = \sum_{n=1}^\infty f(E_n) \left( \sqrt{\frac{m}{2\pi^2\hbar^2}}E_n^{-1/2}\right) \Delta E_n \rightarrow \int f(E) \rho(E) \mathrm dE$$
where $\rho(E) \equiv \sqrt{\frac{m}{2\pi^2\hbar^2 E}}$ is the density of states.
The lesson here is that, in the limit of large $L$, the intuitively-defined but ill-behaved sum of delta functions $\rho_L(E)$ can be "smoothed out" into $\rho(E)$ to first order in $L^{-1}$.  $\rho(E)$ has no explicit $L$-dependence, but its interpretation as the number of states per unit energy per unit volume is an approximation which holds only in the limit of large $L$.


How to avoid this "trick" of using periodic boundary condition in order to find $\langle E\rangle$

In principle, you can work with infinite volume from the outset.  However, it's not difficult to see that the interpretation of the density of states is more subtle here due to the various infinities which are floating around. This is roughly analogous to the situation in classical statistical physics, in which it is useful to discretize phase space into cells of volume $\hbar^3$.
Ultimately, the density of states is important because it quantifies the fact that the energy levels of a system are not uniformly distributed over all possible values.  Different energy ranges have different densities.  The reason this topic is much easier to talk about for a large but finite system is that the energy levels are discrete, so the number in any energy range is finite; for an infinite volume, we can't generically say that the number of states in range $A$ is larger or smaller than the number of states in range $B$ because one or both of those numbers could be infinite.
If the energy eigenstates can be labeled with the continuous variable $k$, then we can define
$$\rho(E) = \int \frac{\mathrm dk}{2\pi} \delta\left( E-\epsilon(k)\right)$$
Being an integral over a delta function, this can be evaluated directly.  Assuming that $\epsilon(k)$ is an even function of $k$, this becomes
$$\rho(E) = \int_0^\infty \frac{\mathrm dk}{\pi}\left|\frac{dk}{d\epsilon}\right|\delta\left(k-\epsilon^{-1}(E)\right) = \frac{1}{\pi}\left|\frac{dk}{d\epsilon}\right|$$
If $\epsilon(k) = \frac{\hbar^2 k^2}{2m}$, we have $\rho(\epsilon)=\sqrt{\frac{m}{2\pi^2\hbar^2 \epsilon}}$.  This reproduces the expression obtained in the $L\rightarrow \infty$ limit of the box-normalized system.
In summary, the expression $\rho(E) = \int \frac{\mathrm dk}{2\pi} \delta\left( E-\epsilon(k)\right)$ is suggestive of an interpretation - roughly, something which quantifies the number of states in an energy interval. Though an integral over delta functions appears somewhat dicey, we find after some manipulation that it is related to the derivative of the dispersion relation (though this relationship may vary somewhat depending on what the dispersion relation actually is).


Does the choice of boundary conditions matter for the density of states ?

No, as you've directly computed yourself.  The spectra of the two Hamiltonians (with fixed and periodic boundary conditions, respectively) are shown here:

The orange circles are for fixed boundary conditions, while the blue circles are for periodic ones.  The spacing between the blue energy levels is twice the spacing between the orange ones, but the blue states are doubly degenerate while the orange ones are nondegenerate.
In the limit as $L\rightarrow 0$, the spacing between these energy levels goes to zero, which means that the spectra (and the density of states) become identical.  For finite $L$, the density of states for periodic and fixed boundaries are not exactly the same.
Physically, this can be understood by noting that the physics of the bulk should be somewhat insensitive to the boundary conditions if the boundaries are very, very far away.  This isn't a hard rule - topological materials feature a very interesting correspondence between their bulk and their boundaries - but it suggests that a physicist who lives in the bulk of a crystal would have a very difficult time obtaining information about the crystal boundaries with any localized experiment.
