model.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:nusa 作者: JorgeDeLosSantos 项目源码 文件源码
def plot_esol(self,var="ux"):
        import matplotlib.pyplot as plt
        import numpy as np
        from matplotlib.patches import Polygon
        from matplotlib.collections import PatchCollection

        fig = plt.figure()
        ax = fig.add_subplot(111)

        _x,_y = [],[]
        patches = []
        for k,elm in enumerate(self.get_elements()):
            _x,_y,_ux,_uy = [],[],[],[]
            for nd in elm.nodes:
                _x.append(nd.x)
                _y.append(nd.y)
            polygon = Polygon(zip(_x,_y), True)
            patches.append(polygon)

        pc = PatchCollection(patches, cmap="jet", alpha=1)
        solutions = {
             "sxx": [e.sx for e in self.get_elements()],
             "syy": [e.sy for e in self.get_elements()],
             "sxy": [e.sxy for e in self.get_elements()],
             "exx": [e.ex for e in self.get_elements()],
             "eyy": [e.ey for e in self.get_elements()],
             "exy": [e.exy for e in self.get_elements()]
             }
        fsol = np.array(solutions.get(var.lower()))
        pc.set_array(fsol)
        ax.add_collection(pc)
        plt.colorbar(pc)
        x0,x1,y0,y1 = self.rect_region()
        ax.set_xlim(x0,x1)
        ax.set_ylim(y0,y1)
        ax.set_aspect("equal")
        ax_title = "{0} (Max:{1}, Min:{2})".format(var,fsol.max(),fsol.min())
        ax.set_title(ax_title)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号