We can wonder what happens if we change the boundary conditions: since they affect only a small part of the system we expect that as long as the system is finite we can observe some differences if we choose different boundary conditions, but as soon as we take the thermodynamic limit these differences become irrelevant.
As an example let us compute again $Z_{N}$ but with periodic boundary conditions, i.e. the first and the last spin are coupled (this can be visually interpreted as "closing" our system in a circle, connecting the first and last spins). In this case we have:

$Z_{N}=\sum _{S_{1}=\pm 1}\cdots \sum _{S_{N}=\pm 1}e^{K(S_{1}S_{2}+\cdots S_{N-1}S_{N})}e^{KS_{N}S_{1}}$

In order to compute this partition function we use another "trick"; we define the variables:

$\eta _{i}={\begin{cases}1&{\text{ if }}S_{i}=S_{i+1}\\-1&{\text{ if }}S_{i}=-S_{i+1}\end{cases}}$

and set

$\eta _{0}=S_{1}$. This way, we can substitute

$S_{i}S_{i+1}$ with

$\eta _{i}$ and since

$S_{i}^{2}=1$ we can also write:

$S_{N}S_{1}=S_{N}S_{N-1}S_{N-1}S_{N-2}\cdots S_{2}S_{1}=\eta _{1}\eta _{2}\cdots \eta _{N-1}$

Therefore, the partition function in terms of

$\eta _{i}$ becomes:

$Z_{N}=\sum _{\eta _{0}=\pm 1}\cdots \sum _{\eta _{N-1}=\pm 1}e^{K(\eta _{1}+\cdots +\eta _{N-1})}e^{K\eta _{1}\cdots \eta _{N-1}}$

Now, summing over

$\eta _{0}$ and rewriting

$e^{K\eta _{1}\cdots \eta _{N-1}}$ with the definition of exponential series:

${\begin{aligned}Z_{N}=2\sum _{\eta _{=}\pm 1}\cdots \sum _{\eta _{N-1}=\pm 1}e^{K(\eta _{1}+\cdots +\eta _{N-1})}\sum _{\alpha =0}^{\infty }{\frac {1}{\alpha !}}(K\eta _{1}\cdots \eta _{N-1})^{\alpha }=\\{}\\=2\sum _{\alpha =0}^{\infty }{\frac {K^{\alpha }}{\alpha !}}\left(\sum _{\eta =\pm 1}\eta ^{\alpha }e^{K\eta }\right)^{N-1}=2\sum _{\alpha =0}^{\infty }{\frac {K^{\alpha }}{\alpha !}}\left[e^{K}+(-1)^{\alpha }e^{-K}\right]^{N-1}=\\{}\\=2\left[(e^{K}+e^{-K})^{N-1}+K(e^{K}-e^{-K})^{N-1}+{\frac {K^{2}}{2!}}(e^{K}+e^{-K})^{N-1}+\right.\\\left.+{\frac {K^{3}}{3!}}(e^{K}-e^{-K})^{N-1}+\cdots \right]=\\{}\\=2\left[2^{N-1}(\cosh K)^{N-1}\left(1+{\frac {K^{2}}{2!}}+{\frac {K^{4}}{4!}}+\cdots \right)+\right.\\\left.+2^{N-1}(\sinh K)^{N-1}\left(K+{\frac {K^{3}}{3!}}+{\frac {K^{5}}{5!}}+\cdots \right)\right]=\\{}\\=2^{N}(\cosh K)^{N-1}\cosh K+2^{N}(\sinh K)^{N-1}\sinh K\end{aligned}}$

Therefore:

$Z_{N}=(2\cosh K)^{N}+(2\sinh K)^{N}$

and the finite-size free energy is:

$F(T)=-k_{B}TN\left\lbrace \ln \left(2\cosh {\frac {J}{k_{B}T}}\right)+{\frac {1}{N}}\ln \left[1+\left(\tanh {\frac {J}{k_{B}T}}\right)^{N}\right]\right\rbrace$

which is different from what we have seen in

Bulk free energy, thermodynamic limit and absence of phase transitions, and as we have already stated this is due to the fact that the system we are considering is still finite-sized. If we now take the thermodynamic limit we will have:

$f(T)=-k_{B}T\ln \left(2\cosh {\frac {J}{k_{B}T}}\right)-k_{B}T\lim _{N\to \infty }{\frac {1}{N}}\ln \left[1+\left(\tanh {\frac {J}{k_{B}T}}\right)^{N}\right]$

The last limit, however, is null: in fact

$\tanh x<1$ for any

$x$ and so as

$N$ grows

$(\tanh x)^{N}$ goes to zero, so

*a fortiori* $(\tanh x)^{N}/N$ vanishes as

$N\to \infty$. Therefore:

$f(T)=-k_{B}T\ln \left(2\cosh {\frac {J}{k_{B}T}}\right)$

which is exactly what we have seen previously.

Since, as expected, the boundary conditions do not affect the properties of macroscopic systems and their effect on finite systems are very small, when we are studying a model we can choose the one we prefer and which makes calculations easier.