Untitled
# Re-importing required libraries to recreate the flowchart after environment reset from matplotlib import pyplot as plt from matplotlib.patches import FancyBboxPatch, Polygon # Function to draw shapes for different flowchart elements def draw_element(ax, text, x, y, width=3, height=1, shape="oval", facecolor="#90EE90"): if shape == "oval": # Terminator (Start/End) ellipse = FancyBboxPatch((x, y), width, height, boxstyle="round,pad=0.3", edgecolor="black", facecolor=facecolor) ax.add_patch(ellipse) elif shape == "rectangle": # Process rect = FancyBboxPatch((x, y), width, height, boxstyle="square,pad=0.3", edgecolor="black", facecolor=facecolor) ax.add_patch(rect) elif shape == "diamond": # Decision diamond = Polygon([ (x + width / 2, y), (x + width, y + height / 2), (x + width / 2, y + height), (x, y + height / 2) ], closed=True, edgecolor="black", facecolor=facecolor) ax.add_patch(diamond) ax.text(x + width / 2, y + height / 2, text, ha="center", va="center", fontsize=10, wrap=True) # Define flowchart elements with correct shapes flow_elements = [ {"text": "Begin", "x": 4, "y": 11, "shape": "oval"}, {"text": "Characterization of c-Si Layers\n• Surface texture\n• ARC materials\n• Refractive index", "x": 4, "y": 9, "shape": "rectangle"}, {"text": "Set Simulation Parameters\n• AM1.5G solar spectrum\n• c-Si material reference", "x": 4, "y": 7, "shape": "rectangle"}, {"text": "Run Simulations\n• Light absorption\n• Reflection analysis", "x": 4, "y": 5, "shape": "rectangle"}, {"text": "Decision:\nAre results valid?", "x": 4, "y": 3, "shape": "diamond"}, {"text": "Calculate J_max\n• J_max Enhancement", "x": 4, "y": 1, "shape": "rectangle"}, {"text": "End", "x": 4, "y": -1, "shape": "oval"} ] # Create figure and axis for flowchart fig, ax = plt.subplots(figsize=(8, 12)) ax.axis("off") # Draw elements for elem in flow_elements: draw_element(ax, elem["text"], elem["x"] - 1.5, elem["y"] - 0.5, shape=elem["shape"]) # Draw arrows connecting elements for i in range(len(flow_elements) - 1): x_start = flow_elements[i]["x"] y_start = flow_elements[i]["y"] - 0.5 x_end = flow_elements[i + 1]["x"] y_end = flow_elements[i + 1]["y"] + 0.5 ax.annotate("", xy=(x_end, y_end), xytext=(x_start, y_start), arrowprops=dict(arrowstyle="->", lw=1.5)) # Save corrected flowchart final_flowchart_path = "/mnt/data/Corrected_FYP_Flowchart.png" plt.savefig(final_flowchart_path, dpi=300, bbox_inches="tight") plt.show()
Leave a Comment