| | 1 | | using Morpho25.Utility; |
| | 2 | | using System; |
| | 3 | | using System.Collections.Generic; |
| | 4 | |
|
| | 5 | |
|
| | 6 | | namespace 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> |
| 3 | 16 | | public IEnumerable<double> Temperature { get; } |
| | 17 | | /// <summary> |
| | 18 | | /// List of relative humidity values to use as boundary condition (%). |
| | 19 | | /// </summary> |
| 2 | 20 | | 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> |
| 6 | 28 | | public SimpleForcing( |
| 6 | 29 | | List<double> temperature, |
| 6 | 30 | | List<double> relativeHumidity) |
| 6 | 31 | | { |
| 6 | 32 | | var temperatureNum = temperature.Count; |
| 6 | 33 | | var relativeHumidityNum = relativeHumidity.Count; |
| | 34 | |
|
| 6 | 35 | | if (temperatureNum != relativeHumidityNum) |
| 1 | 36 | | throw new ArgumentException("Temperature List size = Relative Humidity List size."); |
| | 37 | |
|
| 5 | 38 | | if (temperatureNum != 24 || relativeHumidityNum != 24) |
| 1 | 39 | | throw new ArgumentException("Please, provide 24 values for each variable. Settings of a typical day to u |
| | 40 | |
|
| 4 | 41 | | var temperatureKelvin = new List<double>(); |
| 300 | 42 | | foreach (double num in temperature) temperatureKelvin.Add(num + Util.TO_KELVIN); |
| | 43 | |
|
| | 44 | | // Check rel humidity |
| 236 | 45 | | foreach (double num in relativeHumidity) IsHumidityOk(num); |
| | 46 | |
|
| 3 | 47 | | Temperature = temperatureKelvin; |
| 3 | 48 | | RelativeHumidity = relativeHumidity; |
| 3 | 49 | | } |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// Title of the XML section |
| | 53 | | /// </summary> |
| 1 | 54 | | public string Title => "SimpleForcing"; |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// Values of the XML section |
| | 58 | | /// TODO: It will be updated soon |
| | 59 | | /// </summary> |
| 1 | 60 | | public string[] Values => new[] { |
| 1 | 61 | | String.Join(",", Temperature), |
| 1 | 62 | | String.Join(",", RelativeHumidity) |
| 1 | 63 | | }; |
| | 64 | |
|
| | 65 | | /// <summary> |
| | 66 | | /// Tags of the XML section |
| | 67 | | /// </summary> |
| 1 | 68 | | public string[] Tags => new[] { |
| 1 | 69 | | "TAir", |
| 1 | 70 | | "Qrel" |
| 1 | 71 | | }; |
| | 72 | |
|
| | 73 | | /// <summary> |
| | 74 | | /// String representation of simple forcing settigns. |
| | 75 | | /// </summary> |
| | 76 | | /// <returns>String representation.</returns> |
| 0 | 77 | | public override string ToString() => $"Config::SimpleForcing"; |
| | 78 | | } |
| | 79 | |
|
| | 80 | | } |