File size: 1,227 Bytes
8e5ba9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""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.
    """

    @abstractmethod
    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.
        """

    @property
    @abstractmethod
    def config_id(self) -> str:
        """Unique identifier for this solver configuration."""

    @property
    @abstractmethod
    def problem_family(self) -> str:
        """Problem family: 'beam', 'plate', or 'vessel'."""