I guess one way of putting it, when does the series $\sum\_{x,y \in \mathbb{Z}} q^{x^2+xy+y^2}$ have nonzero coefficients?


The analogous answer for $\sum\_{x,y \in \mathbb{Z}} q^{x^2+y^2}$ is that $q^n$ appears when $\mathrm{ord}\_p(n)$ be even for all primes.


Is there a closed form for either of these with quadratic characters or theta functions or something?n



which integers take the form $x^2 + xy + y^2$?
Let $r\_2(n)$ be the number of representations of $n$ as a sum of two squares, and let $l(n)$ be the number of ways to write $n$ as $x^2+xy+y^2$. Then as you mentioned we have that $$\sum\_{y,x\in \mathbb{Z}} q^{x^2+y^2}=\sum\_{n=0}^\infty r\_2(n) q^n \ \text{and} \ \sum\_{y,x\in \mathbb{Z}} q^{x^2+xy+y^2}=\sum\_{n=0}^\infty l(n) q^n.$$ 


**Exact number of representations:**
We can explicitely write down $r\_2(n)$, the number of representations of $n$ as a sum of two squares. See [Sum of Squares Function.](http://mathworld.wolfram.com/SumofSquaresFunction.html)


Also, in a similar manner we can explicitely write down $l(n)$, the number of representations of $n$ as $x^2+xy+y^2$. See the answer on this [math stack exchange post.](https://math.stackexchange.com/questions/44139/how-many-solutions-are-there-to-fn-m-n2nmm2-q) 


**Theta Functions:**
We can evaluate the infinite series in terms of [Jacobi theta functions](http://mathworld.wolfram.com/JacobiThetaFunctions.html) without much difficulty. To deal with the sum of squares, notice that


$$\sum\_{y,x\in \mathbb{Z}} q^{x^2+y^2} =\left( \sum\_{n=-\infty}^\infty q^{n^2}\right)^2= \vartheta\_3(q)^2.$$
Next, we can transform $x^2 +xy+y^2$ into $\frac{n^2+3m^2}{4}$ where $m,n$ must have the same parity. Then $$\sum\_{x,y}q^{x^{2}+xy+y^{2}}=\sum\_{\begin{array}{c}
x,y\\
both\ odd
\end{array}}q^{\frac{x^{2}+3y^{2}}{4}}+\sum\_{\begin{array}{c}
x,y\\
both\ even
\end{array}}q^{\frac{x^{2}+3y^{2}}{4}} $$


$$=q\sum\_{n,m\in\mathbb{Z}}q^{n(n+1)+3m(m+1)}+\sum\_{n,m\in\mathbb{Z}}q^{n^{2}+3m^{2}}.$$This can be rewritten in terms of the jacobi theta functions as $$\vartheta\_2(q)\vartheta\_2(q^3)+\vartheta\_3(q)\vartheta\_3(q^3).$$


Hope that helps,


