Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,24 +7,39 @@ from simulators.ansys_simulation import run_ansys_simulation
|
|
| 7 |
from visualization import visualize_results
|
| 8 |
|
| 9 |
def simulation_workflow(use_case, simulator, **kwargs):
|
|
|
|
|
|
|
| 10 |
# Generate APDL script based on user inputs
|
| 11 |
if use_case == "plate":
|
|
|
|
| 12 |
apdl_path = generate_plate_apdl(kwargs["thickness"], kwargs["length"], kwargs["width"], kwargs["hole_diameter"], kwargs["force"])
|
| 13 |
elif use_case == "beam":
|
|
|
|
| 14 |
apdl_path = generate_beam_apdl(kwargs["length"], kwargs["width"], kwargs["thickness"], kwargs["load"])
|
| 15 |
else:
|
|
|
|
| 16 |
return "Invalid use case selected.", None, None
|
| 17 |
|
|
|
|
|
|
|
| 18 |
# Run the selected simulator
|
| 19 |
if simulator == "PyCalculix":
|
|
|
|
| 20 |
stress, deformation = run_pycalculix_simulation(use_case, **kwargs)
|
| 21 |
elif simulator == "ANSYS":
|
|
|
|
| 22 |
stress, deformation = run_ansys_simulation(apdl_path)
|
| 23 |
else:
|
|
|
|
| 24 |
return "Invalid simulator selected.", None, None
|
| 25 |
|
|
|
|
|
|
|
| 26 |
# Visualize results (both 2D and 3D)
|
|
|
|
| 27 |
graph_path, three_d_path = visualize_results(simulator, kwargs["length"], kwargs["width"], kwargs["thickness"], stress, deformation)
|
|
|
|
|
|
|
| 28 |
return f"Stress: {stress:.2f} MPa, Deformation: {deformation:.2f} mm", graph_path, three_d_path
|
| 29 |
|
| 30 |
# Define Gradio interface
|
|
@@ -50,4 +65,5 @@ interface = gr.Interface(
|
|
| 50 |
)
|
| 51 |
|
| 52 |
# Launch Gradio interface
|
|
|
|
| 53 |
interface.launch()
|
|
|
|
| 7 |
from visualization import visualize_results
|
| 8 |
|
| 9 |
def simulation_workflow(use_case, simulator, **kwargs):
|
| 10 |
+
print(f"Running simulation for use_case={use_case}, simulator={simulator}")
|
| 11 |
+
|
| 12 |
# Generate APDL script based on user inputs
|
| 13 |
if use_case == "plate":
|
| 14 |
+
print("Generating APDL script for plate simulation...")
|
| 15 |
apdl_path = generate_plate_apdl(kwargs["thickness"], kwargs["length"], kwargs["width"], kwargs["hole_diameter"], kwargs["force"])
|
| 16 |
elif use_case == "beam":
|
| 17 |
+
print("Generating APDL script for beam simulation...")
|
| 18 |
apdl_path = generate_beam_apdl(kwargs["length"], kwargs["width"], kwargs["thickness"], kwargs["load"])
|
| 19 |
else:
|
| 20 |
+
print("Invalid use case selected.")
|
| 21 |
return "Invalid use case selected.", None, None
|
| 22 |
|
| 23 |
+
print(f"APDL script generated at: {apdl_path}")
|
| 24 |
+
|
| 25 |
# Run the selected simulator
|
| 26 |
if simulator == "PyCalculix":
|
| 27 |
+
print("Running PyCalculix simulation...")
|
| 28 |
stress, deformation = run_pycalculix_simulation(use_case, **kwargs)
|
| 29 |
elif simulator == "ANSYS":
|
| 30 |
+
print("Running ANSYS simulation...")
|
| 31 |
stress, deformation = run_ansys_simulation(apdl_path)
|
| 32 |
else:
|
| 33 |
+
print("Invalid simulator selected.")
|
| 34 |
return "Invalid simulator selected.", None, None
|
| 35 |
|
| 36 |
+
print(f"Simulation results - Stress: {stress}, Deformation: {deformation}")
|
| 37 |
+
|
| 38 |
# Visualize results (both 2D and 3D)
|
| 39 |
+
print("Visualizing results...")
|
| 40 |
graph_path, three_d_path = visualize_results(simulator, kwargs["length"], kwargs["width"], kwargs["thickness"], stress, deformation)
|
| 41 |
+
print(f"Visualization paths - 2D: {graph_path}, 3D: {three_d_path}")
|
| 42 |
+
|
| 43 |
return f"Stress: {stress:.2f} MPa, Deformation: {deformation:.2f} mm", graph_path, three_d_path
|
| 44 |
|
| 45 |
# Define Gradio interface
|
|
|
|
| 65 |
)
|
| 66 |
|
| 67 |
# Launch Gradio interface
|
| 68 |
+
print("Launching Gradio interface...")
|
| 69 |
interface.launch()
|