MCPcopy Create free account
hub / github.com/Apress/python-for-matlab-development / main

Function main

pythran/fem/main.py:116–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

114# }}}
115
116def main():
117 tri_model = 'code/mesh/beam.4'
118 if len(sys.argv) == 1:
119 print(f'using default "triangle" model {tri_model}')
120 else:
121 tri_model = sys.argv[1]
122
123 T_top = default_timer()
124 T_s = default_timer()
125 #Model = box_model(elsize='qa=0.8')
126 #Model = torus_model(elsize='qpa0.3')
127 #Model = equitriangle_model(elsize='qa0.005', constrain='bottom_edge')
128 #Model = beam_model(elsize='qa0.0005', constrain='left_edge')
129 #Model = triangle_utils.load_model('code/mesh/simple.1')
130 Model = triangle_utils.load_model(tri_model)
131 T_e = default_timer()
132 print(f'read model file : {T_e-T_s:.6f} s '
133 f'({tri_model})')
134
135 T_s = default_timer()
136 m = FE_model(Model)
137 T_e = default_timer()
138 print(f'FE_model tri->rod {len(m.elem)} elem : {T_e-T_s:.6f} s')
139 #m.show()
140 m.print_summary()
141 #print(m)
142
143 T_s = default_timer()
144 K,M = m.KM()
145 T_e = default_timer()
146 print(f'FE_model K, M {m.nDof:7} dof : {T_e-T_s:.6f} s')
147 #print('exit before modal solution'); sys.exit(0)
148
149 T_s = default_timer()
150 w,v = eigsh(K, k=6, M=M, which='LM', sigma=0)
151 T_e = default_timer()
152 print(f'Eigensolution for {m.nDof:7} dof : {T_e-T_s:.6f} s')
153 print(f'Total : {T_e-T_top:.6f} s')
154
155 iSorted = np.argsort( np.abs(w) )
156
157 print(f'First 6 eigenvalues')
158 for i in range(6):
159 J = iSorted[i]
160 Hz = np.sqrt( np.abs(w[J]) )/(2*np.pi)
161 print(f'{i+1:2d}. {np.real(w[J]):20.3f} {Hz:20.3f} Hz')
162 # mode_shape = m.copy_and_deform(v[:,J])
163 # m.show_comparison(mode_shape, title=f'Mode {i+1} {Hz:.2f} Hz')
164
165if __name__ == "__main__": main()

Callers 1

main.pyFile · 0.70

Calls 3

print_summaryMethod · 0.95
KMMethod · 0.95
FE_modelClass · 0.90

Tested by

no test coverage detected