SteelGrade
def SteelGrade(
name:str, manufacturer:str, bh_data:pd.DataFrame=<factory>, loss_data:pd.DataFrame=<factory>, source_file:str=''
)->None:Container for electrical steel grade properties.
Purpose: Provide realistic material properties for motor design
What it does: Store and query electrical steel material data (B-H curves, core losses).
Motor design requires core loss calculations; lookup actual steel grade (M-19, M-27) properties.
Inputs: Steel grade name, operating frequency, flux density
Outputs: B-H curve data, core loss at given conditions
Upstream (depends on): Feeds material properties to 04_material_models.ipynb and loss calculations
Downstream (used by): See notebook connections
Silicon-steel optimized for low core loss.
Properties: - Silicon content (0.5–3.5%) increases resistivity - Reduces eddy current losses - Laminations further reduce losses
Manufacturers: - Voestalpine (Austria) — ISOVAC - ThyssenKrupp (Germany) — PowerCore - SURA (Sweden) — High-permeability
Container for electrical steel grade properties.
Unified loader for electrical steel manufacturer data.
Supports Voestalpine (isovac), ThyssenKrupp (PowerCore), and SURA grades. Data is loaded from pickle caches on first access and cached in memory.
Args: data_dir: Path to the datasheets root directory.
def load_literature_database(
literature_path:str | Path | None=None, # Path to the datasheets folder. If None, uses the first that exists of:
# - Environment variable EMACHINES_LITERATURE
# - ./KnowledgeBase/literature/datasheets (relative to current dir)
# - ../KnowledgeBase/literature/datasheets
)->"'SteelDatabase'": # Database instance with access to all 51+ steel gradesCreate a SteelDatabase instance from the literature folder.
The literature folder should have this structure:
literature/datasheets/
├── Voelstapine Electrical Steel/ (Excel files)
├── SURA Electrical Steel/ (Excel files)
├── Thyssenkrupp Electrical Steel/ (Excel files)
└── steel_data_cache/ (Pickle files - preprocessed)
├── sura_m470-50a.pkl
├── Simulation-data-isovac310-50A-voestalpine-*.pkl
└── ...
literature_path : str or Path Path to the datasheets folder. If None, uses the first that exists of: - Environment variable EMACHINES_LITERATURE - ./KnowledgeBase/literature/datasheets (relative to current dir) - ../KnowledgeBase/literature/datasheets
SteelDatabase Database instance with access to all 51+ steel grades
FileNotFoundError If no datasheets folder is found.
# Examples
# The real datasheets folder is not part of the repository, so this example
# builds a temporary one in the same layout as steel_data_cache/*.pkl.
#
# TODO(#8): PLACEHOLDER DATA. The grade below and all its numbers are made up
# so the example can run in CI; they are not values of any real steel grade.
# Replace with real datasheet data and update the asserts:
# https://github.com/NaveenDeepak/emachines/issues/8
import math, pickle, tempfile
from pathlib import Path
import pandas as pd
from emachines.magnetics.electrical_steel import load_literature_database
sample = {
"grade": "SAMPLE-GRADE (placeholder)",
"bh_data": pd.DataFrame({"field strength H [A/m]": [0, 100, 500, 1000, 5000],
"B [T]": [0.0, 0.8, 1.2, 1.5, 1.8]}),
"loss_data": pd.DataFrame({"frequency [Hz]": [50, 50, 50, 400, 400, 400],
"B [T]": [0.5, 1.0, 1.5, 0.5, 1.0, 1.5],
"core loss P [W/kg]": [0.6, 1.4, 3.0, 4.5, 13.0, 30.0]}),
}
with tempfile.TemporaryDirectory() as folder:
(Path(folder) / "steel_data_cache").mkdir()
# The loader takes the manufacturer from the file-name prefix (sura_, powercore, ...)
with open(Path(folder) / "steel_data_cache" / "sura_placeholder.pkl", "wb") as f:
pickle.dump(sample, f)
db = load_literature_database(folder) # with no argument: EMACHINES_LITERATURE or ./KnowledgeBase/...
assert db.grades == ["SAMPLE-GRADE (placeholder)"] # all available grades
assert db.manufacturers == {"sura": ["SAMPLE-GRADE (placeholder)"]} # grouped by manufacturer
steel = db.load("SAMPLE-GRADE (placeholder)")
assert steel.frequencies == [50.0, 400.0]
assert math.isclose(steel.loss_at(freq=400, B=1.5), 30.0) # core loss, W/kg
assert math.isclose(steel.loss_at(freq=400, B=1.25), 21.5) # linear interpolation between 1.0 T and 1.5 T
try:
load_literature_database("/no/such/folder")
raise AssertionError("missing folder should raise")
except FileNotFoundError:
passGet the steel database built from the literature folder.
Lazily loads steel grades from the KnowledgeBase/literature folder on first access.
SteelDatabase or None The database (use .grades to list grades and .load(grade) to get a SteelGrade), or None if the literature folder is not found.
Electrical steel database and SteelGrade validation.