# -*- coding: utf-8 -*- """ Created on Sat Dec 26 20:08:51 2020 @author: wenwei bi """ import numpy as np import matplotlib.pyplot as plt import cmath coverage = ["full_cover-middle_layer", "half_cover-lower_layer", "half_cover-middle_layer","half_cover-upper_layer"] for x in coverage: theta1 = np.linspace(0, 2*np.pi/4, 100) if x == "full_cover-middle_layer": r = np.sqrt(1.0)*84.5 elif x == "half_cover-lower_layer": r = np.sqrt(1.0)*cmath.sqrt(84.5**2-(120/2)**2) elif x == "half_cover-middle_layer": r = np.sqrt(1.0)*84.5 else:## x == "half_cover-upper_layer": ## r = np.sqrt(1.0)*cmath.sqrt(84.5**2-(120/2)**2) x1 = r*np.cos(theta1)+10 y1 = r*np.sin(theta1)+10 fig, ax = plt.subplots(1) ax.plot(x1, y1,linewidth=0.3) ax.set_aspect(1) plt.xlim(-100,100) plt.ylim(-100,100) major_ticks = np.arange(-90, 111, 20) ax.set_xticks(major_ticks) ax.set_yticks(major_ticks) ax.grid(which='major', alpha=0.5,linestyle='-') theta2 = np.linspace(2*np.pi/4, 2*np.pi*2/4, 100) x2 = r*np.cos(theta2)-10 y2 = r*np.sin(theta2)+10 ax.plot(x2, y2,linewidth=0.3) ax.set_aspect(1) theta3 = np.linspace(2*np.pi*3/4, 2*np.pi, 100) x3 = r*np.cos(theta3)+10 y3 = r*np.sin(theta3)-10 ax.plot(x3, y3,linewidth=0.3) ax.set_aspect(1) theta4 = np.linspace(2*np.pi*2/4, 2*np.pi*3/4, 100) x4 = r*np.cos(theta4)-10 y4 = r*np.sin(theta4)-10 ax.plot(x4, y4,linewidth=0.3) ax.set_aspect(1) if x == "full_cover-middle_layer": plt.savefig("full_cover-middle_layer.png", dpi=1000) plt.show() elif x == "half_cover-lower_layer": plt.savefig("half_cover-lower_layer.png", dpi=1000) plt.show() elif x == "half_cover-middle_layer": plt.savefig("half_cover-middle_layer.png", dpi=1000) plt.show() else: ##x == "half_cover-upper_layer":## plt.savefig("half_cover-upper_layer.png", dpi=1000) plt.show()