use serde::{Deserialize, Serialize};
use stormath::type_aliases::Float;
pub mod power_model;
pub mod logarithmic_model;
use power_model::PowerModel;
use logarithmic_model::LogarithmicModel;
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum VelocityVariation {
Constant(Float),
PowerModel(PowerModel),
LogarithmicModel(LogarithmicModel),
}
impl VelocityVariation {
pub fn new_constant(velocity: Float) -> Self {
Self::Constant(velocity)
}
pub fn true_wind_velocity_at_height(&self, height: Float) -> Float {
match self {
Self::Constant(value) => *value,
Self::PowerModel(model) => model.velocity_at_height(height),
Self::LogarithmicModel(model) => model.velocity_at_height(height)
}
}
pub fn from_json_string(json_string: &str) -> Self {
serde_json::from_str(json_string).unwrap()
}
pub fn from_json_file(file_path: &str) -> Self {
let json_string = std::fs::read_to_string(file_path).unwrap();
Self::from_json_string(&json_string)
}
}