EvaluatedGridEntry.java

  1. /* Copyright 2022-2025 Thales Alenia Space
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.models.earth.weather;

  18. import org.hipparchus.util.FastMath;
  19. import org.orekit.utils.Constants;

  20. import java.util.Map;

  21. /** Grid entry in Global Pressure Temperature models, evaluated at some date.
  22.  * @author Luc Maisonobe
  23.  * @since 13.0
  24.  */
  25. class EvaluatedGridEntry {

  26.     /** Standard gravity constant [m/s²]. */
  27.     private static final double G = Constants.G0_STANDARD_GRAVITY;

  28.     /** Molar mass of dry air in kg/mol. */
  29.     private static final double DMTR = 28.965e-3;

  30.     /** Universal gas constant in J/K/mol. */
  31.     private static final double RG = 8.3143;

  32.     /** Underlying fixed grid entry. */
  33.     private final GridEntry entry;

  34.     /** Corrected height. */
  35.     private final double correctedHeight;

  36.     /** Virtual temperature factor. */
  37.     private final double factor;

  38.     /** Evaluated seasonal models. */
  39.     private final Map<SeasonalModelType, Double> evaluatedModels;

  40.     /** Build an entry from its components.
  41.      * @param entry underlying fixed entry
  42.      * @param altitude altitude
  43.      * @param evaluatedModels evaluated models
  44.      */
  45.     EvaluatedGridEntry(final GridEntry entry, final double altitude,
  46.                        final Map<SeasonalModelType, Double> evaluatedModels) {
  47.         this.entry           = entry;
  48.         this.evaluatedModels = evaluatedModels;
  49.         this.correctedHeight = altitude - entry.getUndulation() - entry.getHs();
  50.         final double t0 = getEvaluatedModel(SeasonalModelType.TEMPERATURE);
  51.         final double qv = getEvaluatedModel(SeasonalModelType.QV) * 0.001;
  52.         final double tv = t0 * (1 + 0.6077 * qv);
  53.         this.factor     = -correctedHeight * G * DMTR / (RG * tv);
  54.     }

  55.     /** Get underlying fixed entry.
  56.      * @return underlying fixed entry
  57.      */
  58.     public GridEntry getEntry() {
  59.         return entry;
  60.     }

  61.     /** Get evaluated model.
  62.      * @param type model type
  63.      * @return evaluated model type
  64.      */
  65.     public double getEvaluatedModel(final SeasonalModelType type) {
  66.         return evaluatedModels.get(type);
  67.     }

  68.     /** Get temperature.
  69.      * @return temperature
  70.      */
  71.     public double getTemperature() {
  72.         final double t0   = getEvaluatedModel(SeasonalModelType.TEMPERATURE);
  73.         final double dtdh = getEvaluatedModel(SeasonalModelType.DT) * 0.001;
  74.         return t0 + dtdh * correctedHeight;
  75.     }

  76.     /** Get pressure.
  77.      * @return pressure
  78.      */
  79.     public double getPressure() {
  80.         final double p0 = getEvaluatedModel(SeasonalModelType.PRESSURE) * 0.01;
  81.         return p0 * FastMath.exp(factor);
  82.     }

  83.     /** Get water vapor pressure.
  84.      * <p>
  85.      * This applies only to GPT2w and GPT3 as GPT2 does not have water vapor decrease factor λ
  86.      * </p>
  87.      * @return water vapor pressure
  88.      */
  89.     public double getWaterVaporPressure() {
  90.         final double p0     = getEvaluatedModel(SeasonalModelType.PRESSURE) * 0.01;
  91.         final double qv     = getEvaluatedModel(SeasonalModelType.QV) * 0.001;
  92.         final double e0     = qv * p0 / (0.622 + 0.378 * qv);
  93.         final double lambda = getEvaluatedModel(SeasonalModelType.LAMBDA);
  94.         return e0 * FastMath.exp(factor * (1 + lambda));
  95.     }

  96. }