From 2e9596e2b70a57364411307393359aa4a78a447e Mon Sep 17 00:00:00 2001 From: Lisa Rueben <78411130+lruebli@users.noreply.github.com> Date: Thu, 2 May 2024 15:59:26 +0200 Subject: [PATCH] additional check of length of experimental permittivity data > 0 (#242) * added additional check if more than 0 permittivity points have been provided during creation of parameters --------- Co-authored-by: LisaNeumaier --- src/epcsaft/parameters.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/epcsaft/parameters.rs b/src/epcsaft/parameters.rs index 21ef0407c..7806a82f9 100644 --- a/src/epcsaft/parameters.rs +++ b/src/epcsaft/parameters.rs @@ -469,6 +469,21 @@ impl Parameter for ElectrolytePcSaftParameters { )); } + if !modeltypes.is_empty() && modeltypes[0] == 2 { + for permittivity_record in &permittivity_records { + if let Some(PermittivityRecord::ExperimentalData { data }) = + permittivity_record.as_ref() + { + // check if length of data is greater than 0 + if data.is_empty() { + return Err(ParameterError::IncompatibleParameters( + "Experimental data for permittivity must contain at least one data point.".to_string(), + )); + } + } + } + } + if !modeltypes.is_empty() && modeltypes[0] == 2 { // order points in data by increasing temperature let mut permittivity_records_clone = permittivity_records.clone();