Пример #1
0
        /// <summary>
        /// Set the value of a solute by specifying a delta. Will throw if solute not found.
        /// </summary>
        /// <param name="name">Name of solute</param>
        /// <param name="callingModelType">Type of calling model</param>
        /// <param name="delta">Delta values to be added to solute</param>
        public void Add(string name, SoluteSetterType callingModelType, double[] delta)
        {
            Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

            if (foundSolute == null)
            {
                throw new Exception("Cannot find solute: " + name);
            }
            foundSolute.SetValue(callingModelType, MathUtilities.Add(foundSolute.GetValue(), delta));
        }
Пример #2
0
        /// <summary>
        /// Add a delta value to the top layer of a solute. Will throw if solute not found.
        /// </summary>
        /// <param name="name">Name of solute</param>
        /// <param name="callingModelType">Type of calling model</param>
        /// <param name="layerIndex">Layer index to add delta to</param>
        /// <param name="delta">Value to be added to top layer of solute</param>
        public void AddToLayer(int layerIndex, string name, SoluteSetterType callingModelType, double delta)
        {
            Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

            if (foundSolute == null)
            {
                throw new Exception("Cannot find solute: " + name);
            }

            double[] values = foundSolute.GetValue();
            values[layerIndex] += delta;
            foundSolute.SetValue(callingModelType, values);
        }
Пример #3
0
        /// <summary>
        /// Return the value of a solute. Will throw if solute not found.
        /// </summary>
        /// <param name="name">Name of solute</param>
        public double[] GetSolute(string name)
        {
            if (solutes == null)
            {
                FindSolutes();
            }
            Solute foundSolute = solutes.Find(solute => solute.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

            if (foundSolute == null)
            {
                throw new Exception("Cannot find solute: " + name);
            }
            return(foundSolute.GetValue());
        }