diff --git a/ex/buckle.py b/ex/buckle.py index b5b6d7e2feec2b0d4b9a67e85d7d13b120926bfb..bd09e669c03d2c50d5d6fff85cc6626a22850e8f 100644 --- a/ex/buckle.py +++ b/ex/buckle.py @@ -6,6 +6,18 @@ from pyframe3dd.frame3dd import write_frame3dd_file, read_lowest_mode, read_fram from pyframe3dd.util import magnitudes, close import subprocess +def plot_connections(nodes,connect): + #for debug only, this is slow! + import matplotlib as mpl + from mpl_toolkits.mplot3d import Axes3D + import numpy as np + import matplotlib.pyplot as plt + fig = plt.figure() + ax = fig.gca(projection='3d') + for seg in connect: + ax.plot(nodes[seg,0], nodes[seg,1], nodes[seg,2], c='g') + plt.show() + def run_frame3dd(args,nodes,global_args,beam_sets,constraints,loads): write_frame3dd_file(nodes,global_args,beam_sets,constraints,loads) cmd = ["frame3dd", "-i",global_args['frame3dd_filename']+'.csv'] @@ -85,7 +97,7 @@ def find_stability_threshold(args): if __name__ == '__main__': parser = argparse.ArgumentParser() - parser.add_argument('-M','--mode',choices=('simulate','search'), required=True) + parser.add_argument('-M','--mode',choices=('simulate','search', 'visualize'), required=True) parser.add_argument('-Q','--quiet',action='store_true',help='Whether to suppress frame3dd output') parser.add_argument("-f","--force", type=double, default=1, help="force to apply") parser.add_argument("-fr","--force_res", type=double, default=.01, help="Final resolution of force for search mode") @@ -112,6 +124,9 @@ if __name__ == '__main__': res = run_simulation(args) print "Fundamental frequency: %.3f Hz"%res['fundamental_frequency'] print "Stress: %.3f MPa"%(res['stress']/1e6) + elif args.mode=='visualize': + nodes,rods = build(args) + plot_connections(nodes,rods) else: assert(0) #should not be here