/// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (copasi != null)
     {
         copasi.Dispose();
         copasi = null;
     }
 }
        /// <summary>
        /// Reload data from CUE
        /// </summary>
        public void Reload()
        {
            // reset data

            reactionList.Clear();

            if (copasi != null)
            {
                copasi.Dispose();
                copasi = null;
            }

            copasi = new Copasi();

            copasi.UpdateCompartmentVolume(cue.Volume);

            foreach (var item in cue.Species)
            {
                copasi.AddSpecies(item);

                copasi.UpdateSpeciesQuantity(
                    copasi.GetMetab(item),
                    cue.Molecules.GetQuantity(item)
                    );
            }

            foreach (var item in cue.ReactionTypes)
            {
                ReactionType reactionType   = item;
                CReaction    copasiReaction = copasi.AddReaction(reactionType);
                CModelValue  modelValue     = copasi.AddReactionParticleFluxValue(copasiReaction);

                reactionList.Add(new CopasiReactionGroup(copasiReaction, reactionType, modelValue));
            }

            copasi.InitTrajectoryTask();

            UnityEngine.Debug.Log("copasi: compiling...");
            copasi.CompileAndUpdate();
            UnityEngine.Debug.Log("copasi: saving...");
            copasi.SaveModel("model.cps");
            UnityEngine.Debug.Log("copasi: model updated");

            currentTime = 0;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CellUnity.Simulation.Copasi.CopasiSimulator"/> class.
 /// </summary>
 public CopasiSimulator()
 {
     copasi = new Copasi();
 }