write cosine during simulation (duh...)