Express $\sum_{n\in\mathbb{Z}} \left ( q^{(8n+1)^2}-q^{(8n+3)^2}\right )$ How can we find a expression for the following sum
$$
S=\sum_{n\in\mathbb{Z}}
\left ( q^{(8n+1)^2}-q^{(8n+3)^2}\right )
$$
where $q=e^{-\pi{K^\prime(k)}/{K(k)}}$
and $K(x)=\int_{0}^{1} \frac{1}{\sqrt{1-t^2}\sqrt{1-x^2t^2}  }
\text{d}t,K^\prime(x)=K\left(\sqrt{1-x^2}\right)$ is the complete elliptic integral of the first kind?

Motivation.
We observe that
$$
\sum_{n\in\mathbb{Z}}q^{\left ( 4n+1\right )^2 }=\frac12\vartheta_2(q^4),\\
\sum_{n\in\mathbb{Z}}\left ( 4n+1\right ) q^{\left ( 4n+1\right )^2 }=\eta(4ix)^3.
$$
I have some good reasons to generalize those two formulae. In fact,
$$
S=\frac{1}{2} \sum_{n\in\mathbb{Z}/\{0\}}\left ( \frac{8}{n}  \right )
q^{n^2}
$$
and $\left(\frac{m}{n}\right)$ is the Kronecker symbol.

I am very thankful for all your help and advice.
 A: Let us write $S=A-B$ and then we can observe that $A+B=\vartheta_2(q^4)/2$ and $AB$ can also be evaluated in closed form and thus $S^2$ can be evaluated.
Let us use the Ramanujan theta function $$f(a, b) =\sum_{n\in\mathbb{Z}} a^{n(n+1)/2}b^{n(n-1)/2},|ab|<1\tag{1}$$ and then the Jacobi Triple Product can be written as $$f(a, b) =\prod_{n=1}^{\infty}(1-(ab)^n)(1+a(ab)^{n-1})(1+b(ab)^{n-1})\tag{2}$$ To reduce typing effort let us make a convention that summation index $n$ varies over all integers unless indicated otherwise explicitly. Also let $p=q^{16}$ and then $$A=\sum q^{(8n+1)^2}=q\sum p^{n(4n+1)}=qf(p^3,p^5)=q\prod_{n=1}^{\infty}(1-p^{8n})(1+p^{8n-3})(1+p^{8n-5})$$ and similarly $$B=q^9\prod_{n=1}^{\infty}(1-p^{8n})(1+p^{8n-1})(1+p^{8n-7})$$ We have therefore $$AB=q^{10}\prod_{n=1}^{\infty}(1-p^{8n})^2(1+p^{2n-1})$$ which can be evaluated in terms of Dedekind's eta function.
Using a series of Landen transformations it is possible to get expressions for both $A+B$ and $AB$ in terms of elliptic moduli $k, k'$ and elliptic integral $K$.
A: Your function is
$$\sum_{n\in \Bbb{Z}}\frac1{32} \sum_{k=0}^{15}(e^{-2i\pi k/16}-e^{-2i\pi k9/16})  e^{2i\pi kn^2/16} q^{n^2}=\frac1{32} \sum_{k=0}^{15}(e^{-2i\pi k/16}-e^{-2i\pi k9/16})\theta(e^{2i\pi k/16} q)$$
