From 669fa454dcc54f9310be61d898e756695f6cd911 Mon Sep 17 00:00:00 2001
From: Rahil Doshi <rahil.doshi@fau.de>
Date: Wed, 12 Mar 2025 17:45:41 +0100
Subject: [PATCH] Add new yaml config for testing, update models and parser

---
 src/pymatlib/core/models.py                   |  4 +-
 src/pymatlib/core/yaml_parser.py              |  2 +-
 .../alloys/SS304L/SS304L_comprehensive.yaml   | 61 +++++++++++++++++++
 3 files changed, 64 insertions(+), 3 deletions(-)
 create mode 100644 src/pymatlib/data/alloys/SS304L/SS304L_comprehensive.yaml

diff --git a/src/pymatlib/core/models.py b/src/pymatlib/core/models.py
index 621b0d7..0a0bab2 100644
--- a/src/pymatlib/core/models.py
+++ b/src/pymatlib/core/models.py
@@ -27,8 +27,8 @@ def wrapper(value: Union[sp.Expr, NumericType, ArrayTypes, MaterialProperty]) \
     if isinstance(value, sp.Expr):
         return sp.simplify(value)
     if isinstance(value, (float, np.int32, np.int64, np.float32, np.float64)):  # np.floating
-        if abs(value) < DEFAULT_TOLERANCE:
-            return sp.Float(0.0)
+        # if abs(value) < DEFAULT_TOLERANCE:
+            # return sp.Float(0.0)
         return sp.Float(float(value))
     if isinstance(value, ArrayTypes):  # Handles lists, tuples, and arrays
         try:
diff --git a/src/pymatlib/core/yaml_parser.py b/src/pymatlib/core/yaml_parser.py
index 26ae0be..01d2582 100644
--- a/src/pymatlib/core/yaml_parser.py
+++ b/src/pymatlib/core/yaml_parser.py
@@ -217,7 +217,7 @@ class MaterialConfigParser:
                     raise ValueError(f"'{prop_name}' cannot be negative, got {prop_value}")
 
             if prop_name == 'thermal_expansion_coefficient':
-                if isinstance(prop_value, float) and prop_value < -3e-5 or prop_value > 0.001:
+                if isinstance(prop_value, float) and (prop_value < -3e-5 or prop_value > 0.001):
                     raise ValueError(f"'thermal_expansion_coefficient' value {prop_value} is outside the expected range (-3e-5/K to 0.001/K)")
 
             if prop_name == 'energy_density_temperature_array':
diff --git a/src/pymatlib/data/alloys/SS304L/SS304L_comprehensive.yaml b/src/pymatlib/data/alloys/SS304L/SS304L_comprehensive.yaml
new file mode 100644
index 0000000..1db622c
--- /dev/null
+++ b/src/pymatlib/data/alloys/SS304L/SS304L_comprehensive.yaml
@@ -0,0 +1,61 @@
+name: SS304L_Comprehensive
+
+composition:
+  Fe: 0.675
+  Cr: 0.170
+  Ni: 0.120
+  Mo: 0.025
+  Mn: 0.010
+
+solidus_temperature: 1605
+liquidus_temperature: 1735
+
+properties:
+  # 1. Constant float property
+  density: 7950.  # kg/m³
+
+  # 2.1 File-based property (simple format)
+  heat_conductivity: ./heat_conductivity_temperature.txt
+
+  # 2.2 File-based property (advanced format)
+  specific_enthalpy:
+    file: ./304L_Erstarrungsdaten_edited.xlsx
+    temp_col: T (K)
+    prop_col: Enthalpy (J/kg)
+
+  # 3.1 Key-val pair with explicit temperature list
+  heat_capacity:
+    key: [1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800]
+    val: [580, 590, 600, 600, 600, 610, 620, 630, 660, 700]
+
+  # 3.2 Key-val pair with references to defined temperatures
+  latent_heat_of_fusion:
+    key: [solidus_temperature, liquidus_temperature]
+    val: [171401, 0]
+
+  # 3.3 Key-val pair with tuple for temperature generation (increment)
+  thermal_expansion_coefficient:
+    key: (300, 100)  # Start at 300K and increment by 100K
+    val: [16.3e-6, 16.5e-6, 16.8e-6, 17.0e-6, 17.2e-6]
+
+  # 3.4 Key-val pair with tuple for temperature generation (decrement)
+  dynamic_viscosity:
+    key: (1735, -10)  # Start at 1735K and decrement by 10K
+    val: [0.005, 0.006, 0.007, 0.008, 0.009]
+
+  # 4.1 Computed property (simple format)
+  thermal_diffusivity: compute  # k/(rho*cp)
+
+  # 4.2 Computed property (advanced format with model selection)
+  energy_density:
+    compute: total_enthalpy
+
+  # Required for energy_density computation (with number of points)
+  # energy_density_temperature_array: (300, 3000, 541)
+
+  # Alternative specification (with temperature increment)
+  energy_density_temperature_array: (300, 3000, 5.0)
+
+  # Properties required for density computation by thermal expansion
+  base_temperature: 2273.
+  base_density: 6.591878918e3
-- 
GitLab