< Summary

Information
Class: Morpho25.Settings.SimpleForcing
Assembly: Morpho25
File(s): D:\a\Morpho\Morpho\project\Morpho\Morpho25\Settings\SimpleForcing.cs
Line coverage
96%
Covered lines: 27
Uncovered lines: 1
Coverable lines: 28
Total lines: 80
Line coverage: 96.4%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_Temperature()100%1100%
get_RelativeHumidity()100%1100%
.ctor(...)100%10100%
get_Title()100%1100%
get_Values()100%1100%
get_Tags()100%1100%
ToString()100%10%

File(s)

D:\a\Morpho\Morpho\project\Morpho\Morpho25\Settings\SimpleForcing.cs

#LineLine coverage
 1using Morpho25.Utility;
 2using System;
 3using System.Collections.Generic;
 4
 5
 6namespace Morpho25.Settings
 7{
 8    /// <summary>
 9    /// Simple forcing class.
 10    /// </summary>
 11    public class SimpleForcing : Configuration
 12    {
 13        /// <summary>
 14        /// List of temperature values to use as boundary condition (°C).
 15        /// </summary>
 316        public IEnumerable<double> Temperature { get; }
 17        /// <summary>
 18        /// List of relative humidity values to use as boundary condition (%).
 19        /// </summary>
 220        public IEnumerable<double> RelativeHumidity { get; }
 21
 22        /// <summary>
 23        /// Create a simple forcing object.
 24        /// </summary>
 25        /// <param name="temperature">List of temperature values to use as boundary condition (°C).</param>
 26        /// <param name="relativeHumidity">List of relative humidity values to use as boundary condition (%)</param>
 27        /// <exception cref="ArgumentException">Wrong number of values</exception>
 628        public SimpleForcing(
 629            List<double> temperature,
 630            List<double> relativeHumidity)
 631        {
 632            var temperatureNum = temperature.Count;
 633            var relativeHumidityNum = relativeHumidity.Count;
 34
 635            if (temperatureNum != relativeHumidityNum)
 136                throw new ArgumentException("Temperature List size = Relative Humidity List size.");
 37
 538            if (temperatureNum != 24 || relativeHumidityNum != 24)
 139                throw new ArgumentException("Please, provide 24 values for each variable. Settings of a typical day to u
 40
 441            var temperatureKelvin = new List<double>();
 30042            foreach (double num in temperature) temperatureKelvin.Add(num + Util.TO_KELVIN);
 43
 44            // Check rel humidity
 23645            foreach (double num in relativeHumidity) IsHumidityOk(num);
 46
 347            Temperature = temperatureKelvin;
 348            RelativeHumidity = relativeHumidity;
 349        }
 50
 51        /// <summary>
 52        /// Title of the XML section
 53        /// </summary>
 154        public string Title => "SimpleForcing";
 55
 56        /// <summary>
 57        /// Values of the XML section
 58        /// TODO: It will be updated soon
 59        /// </summary>
 160        public string[] Values => new[] {
 161            String.Join(",", Temperature),
 162            String.Join(",", RelativeHumidity)
 163        };
 64
 65        /// <summary>
 66        /// Tags of the XML section
 67        /// </summary>
 168        public string[] Tags => new[] {
 169            "TAir",
 170            "Qrel"
 171        };
 72
 73        /// <summary>
 74        /// String representation of simple forcing settigns.
 75        /// </summary>
 76        /// <returns>String representation.</returns>
 077        public override string ToString() => $"Config::SimpleForcing";
 78    }
 79
 80}