File size: 996 Bytes
0393146
 
 
729a44c
ddc918b
729a44c
 
 
 
 
 
 
 
 
 
ddc918b
729a44c
ddc918b
 
0393146
ddc918b
 
 
729a44c
ddc918b
 
 
 
729a44c
ddc918b
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
import matplotlib.pyplot as plt

def visualize_results(simulator, length, width, thickness, stress, deformation):
    """
    Generates 2D visualizations for simulation results.

    Parameters:
        simulator (str): Name of the simulator (e.g., 'Python-Based Solver').
        length (float): Length of the object.
        width (float): Width of the object.
        thickness (float): Thickness of the object.
        stress (float): Stress value.
        deformation (float): Deformation value.

    Returns:
        str: Path to the 2D visualization image.
    """
    # Generate 2D bar chart
    fig, ax = plt.subplots(figsize=(6, 4))
    ax.bar(["Stress", "Deformation"], [stress, deformation], color=["red", "blue"])
    ax.set_title(f"Simulation Results ({simulator})")
    ax.set_ylabel("Magnitude")
    ax.grid(True, linestyle="--", alpha=0.6)
    
    # Save the chart
    output_path = "results_2d.png"
    plt.savefig(output_path)
    plt.close(fig)

    return output_path, None