# Problem with $CellContext in Animation

**URL:** <https://community.wolfram.com/t/problem-with-cellcontext-in-animation/21635>\
**Category:** Questions\
**Tags:** graphics-and-visualization, tuning-and-debugging\
**Created:** [February 20, 2023, 7:34pm UTC](https://community.wolfram.com/t/problem-with-cellcontext-in-animation/21635 "2023-02-20T19:34:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbark](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@jbark](https://community.wolfram.com/u/jbark)\
**Post date:** [February 20, 2023, 7:34pm UTC](https://community.wolfram.com/t/problem-with-cellcontext-in-animation/21635/1 "2023-02-20T19:34:01Z")

</div>

I have some code here, that worked fine 10 or 20 years ago. Now it won’t animate any more and seems to have a problem with $CellContext of variable t. ChatGPT suggested wrapping Animate with DynamicModule[{t},…], but that didn’t help. Does anyone know, what’s wrong? Here is the code:

```
AnzahlBilder = b = 18;
numberOfAtoms = 120;
cylRadius = 20;
waveLength = 0.4*cylRadius;
waveConstant = N[2Pi/waveLength];
amplitude = 0.10*waveLength;
angularFrequency = N[2Pi];
fromXAndYToPhiAndR[{x_,y_}] := {ArcTan[x,y], Sqrt[x^2+y^2]}
fromPhiAndRToXAndY[{phi_,r_}] := r*{Cos[phi],Sin[phi]}

coordinatesOfAtoms = Table[
	{Random[Real,{-cylRadius,cylRadius}], 
	Random[Real,{-cylRadius,cylRadius}]},
	{numberOfAtoms}];
	
cylCoorOfAtoms = Map[fromXAndYToPhiAndR, coordinatesOfAtoms];

displaceAtom[{phi_,r_}] := {phi, 
	Max[0, r + amplitude*Sin[waveConstant*r - angularFrequency*t]]}

Animate[Graphics[Map[Point, Map[fromPhiAndRToXAndY,
Map[displaceAtom, cylCoorOfAtoms]]]], {t, 0, 1-1/b, 1/b}]

```

---

<div class="post-metadata">

**Author:** ![jbark](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@jbark](https://community.wolfram.com/u/jbark)\
**Post date:** [February 21, 2023, 12:28pm UTC](https://community.wolfram.com/t/problem-with-cellcontext-in-animation/21635/2 "2023-02-21T12:28:38Z")

</div>

I changed the last line to

```
ListAnimate[
 Table[Graphics[
   Map[Point, 
    Map[fromPhiAndRToXAndY, Map[displaceAtom, cylCoorOfAtoms]]]], {t, 
   0, 1 - 1/b, 1/b}]]

```

Now it is working. I would liked to understand the problem, though. Documentation is not too great. Thanks if someone tried to figure it out for me. The animation, by the way, shows air molecules in motion (spherical model). Set numberOfAtoms to 1200.
