Spaces:
Sleeping
Sleeping
Download src/data/solvers/base.py from WolfDavid/fea-surrogate: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/WolfDavid/fea-surrogate/resolve/main/src/data/solvers/base.py
- Command line
-
hf download hf://spaces/WolfDavid/fea-surrogate/src/data/solvers/base.py
-
curl -L -o base.py https://huggingface.co/spaces/WolfDavid/fea-surrogate/resolve/main/src/data/solvers/base.py
1.23 kB
| """Abstract base class for analytical structural solvers. | |
| Every solver implements exact closed-form solutions from classical mechanics. | |
| No numerical approximation — these are the ground truth the neural surrogate | |
| learns to approximate. | |
| """ | |
| from abc import ABC, abstractmethod | |
| from typing import Any | |
| from src.data.schema import SolutionResult | |
| class AnalyticalSolver(ABC): | |
| """Base class for all analytical structural solvers. | |
| Each subclass implements solve() for a specific structural element | |
| (beam, plate, pressure vessel) using exact closed-form equations. | |
| """ | |
| def solve(self, params: dict[str, Any]) -> SolutionResult: | |
| """Compute analytical solution for given parameters. | |
| Args: | |
| params: Dictionary of input parameters (geometry, material, loading). | |
| Returns: | |
| SolutionResult with max_stress, max_deflection, safety_factor, | |
| and safety_category. | |
| """ | |
| def config_id(self) -> str: | |
| """Unique identifier for this solver configuration.""" | |
| def problem_family(self) -> str: | |
| """Problem family: 'beam', 'plate', or 'vessel'.""" | |