2
9.12.2014 transfert.lmgc.univmontp2.fr/~averseng/JA/ToyGL_files/test_tgl.py http://transfert.lmgc.univmontp2.fr/~averseng/JA/ToyGL_files/test_tgl.py 1/2 #!/usr/bin/env python # ‐*‐ coding:Utf‐8 ‐*‐ import ToyGLStructure as tgls from numpy import * def class_1_tensegrity_module_n_h_r(n = 3,h = 1.,r_base = 0.5, r_top = 0.5, theta0 = 0.): """ A function that generates a class 1 tensegrity modules Parameters : ‐ n : number of struts (default = 3) ‐ h : height (default = 1m) ‐ r_base and r_top (default = 0.5m) ‐ theta0 : the initial angle (default : 0.) Default characteristics and colors are associated to the different types of elements """ s0 = tgls.ToyGLStructure() # Definition of families fam_nodes = 0 fam_struts, fam_layer_cables, fam_diagonal_cables = 0,1,2 # Setting default characteristics (only visual) s0.set_node_family_mass_radius_color(fam_nodes,1.,0.05,[0.,0.,0.]) # nodes s0.set_element_family_radius_color(fam_struts,0.03,[1.,0.,0.]) # struts s0.set_element_family_radius_color(fam_layer_cables,0.01,[0.,1.,0.]) # layer cables s0.set_element_family_radius_color(fam_diagonal_cables,0.01,[0.,0.,1.]) # diagonal cables # Generating the system for i in range(n): # angles dtheta = 2.*pi/n ang_shift = pi/2. ‐ 1. * pi/n theta_base = i*dtheta + theta0 theta_top = theta_base + ang_shift # points : current and next one (p), at the base (1) and top (2) pt1 = [r_base*cos(theta_base) , r_base*sin(theta_base) , 0] pt1p = [r_base*cos(theta_base + dtheta) , r_base*sin(theta_base + dtheta) , 0] pt2 = [r_top*cos(theta_top) , r_top*sin(theta_top) , h] pt2p = [r_top*cos(theta_top + dtheta) , r_top*sin(theta_top + dtheta) , h] # elements : 1 strut, 2 layers cables and 1 diagonal cable s0.create_element_pt1_f1_pt2_f2_fam(pt1,fam_nodes,pt2p,fam_nodes,fam_struts) s0.create_element_pt1_f1_pt2_f2_fam(pt1,fam_nodes,pt1p,fam_nodes,fam_layer_cables) s0.create_element_pt1_f1_pt2_f2_fam(pt2,fam_nodes,pt2p,fam_nodes,fam_layer_cables) s0.create_element_pt1_f1_pt2_f2_fam(pt1,fam_nodes,pt2,fam_nodes,fam_diagonal_cables) return s0 # main program if __name__ == "__main__": # simple module with 3 struts, r_base = 0.5m and r_top = 1m print "A simple module" module = class_1_tensegrity_module_n_h_r(3,1.,0.5,1) module.save_for_toygl("TestTgl_module.txt") # a grid of 4 bars modules print "A grid of 4 bar modules" nx,ny = 8,8 r0,h0 = 0.5,1.

transfert.lmgc.univ-montp2.fr_~averseng_JA_ToyGL_files_test_tgl

  • Upload
    nie

  • View
    33

  • Download
    2

Embed Size (px)

DESCRIPTION

Estructuras

Citation preview

  • 9.12.2014 transfert.lmgc.univmontp2.fr/~averseng/JA/ToyGL_files/test_tgl.py

    http://transfert.lmgc.univmontp2.fr/~averseng/JA/ToyGL_files/test_tgl.py 1/2

    #!/usr/bin/envpython#*coding:Utf8*

    importToyGLStructureastglsfromnumpyimport*

    defclass_1_tensegrity_module_n_h_r(n=3,h=1.,r_base=0.5,r_top=0.5,theta0=0.):"""Afunctionthatgeneratesaclass1tensegritymodulesParameters:n:numberofstruts(default=3)h:height(default=1m)r_baseandr_top(default=0.5m)theta0:theinitialangle(default:0.)Defaultcharacteristicsandcolorsareassociatedtothedifferenttypesofelements"""s0=tgls.ToyGLStructure()#Definitionoffamiliesfam_nodes=0fam_struts,fam_layer_cables,fam_diagonal_cables=0,1,2

    #Settingdefaultcharacteristics(onlyvisual)s0.set_node_family_mass_radius_color(fam_nodes,1.,0.05,[0.,0.,0.])#nodess0.set_element_family_radius_color(fam_struts,0.03,[1.,0.,0.])#strutss0.set_element_family_radius_color(fam_layer_cables,0.01,[0.,1.,0.])#layercabless0.set_element_family_radius_color(fam_diagonal_cables,0.01,[0.,0.,1.])#diagonalcables#Generatingthesystemforiinrange(n):#anglesdtheta=2.*pi/nang_shift=pi/2.1.*pi/ntheta_base=i*dtheta+theta0theta_top=theta_base+ang_shift#points:currentandnextone(p),atthebase(1)andtop(2)pt1=[r_base*cos(theta_base),r_base*sin(theta_base),0]pt1p=[r_base*cos(theta_base+dtheta),r_base*sin(theta_base+dtheta),0]pt2=[r_top*cos(theta_top),r_top*sin(theta_top),h]pt2p=[r_top*cos(theta_top+dtheta),r_top*sin(theta_top+dtheta),h]#elements:1strut,2layerscablesand1diagonalcables0.create_element_pt1_f1_pt2_f2_fam(pt1,fam_nodes,pt2p,fam_nodes,fam_struts)s0.create_element_pt1_f1_pt2_f2_fam(pt1,fam_nodes,pt1p,fam_nodes,fam_layer_cables)s0.create_element_pt1_f1_pt2_f2_fam(pt2,fam_nodes,pt2p,fam_nodes,fam_layer_cables)s0.create_element_pt1_f1_pt2_f2_fam(pt1,fam_nodes,pt2,fam_nodes,fam_diagonal_cables)returns0

    #mainprogramif__name__=="__main__":#simplemodulewith3struts,r_base=0.5mandr_top=1mprint"Asimplemodule"module=class_1_tensegrity_module_n_h_r(3,1.,0.5,1)module.save_for_toygl("TestTgl_module.txt")#agridof4barsmodulesprint"Agridof4barmodules"nx,ny=8,8r0,h0=0.5,1.

  • 9.12.2014 transfert.lmgc.univmontp2.fr/~averseng/JA/ToyGL_files/test_tgl.py

    http://transfert.lmgc.univmontp2.fr/~averseng/JA/ToyGL_files/test_tgl.py 2/2

    nbars=4module4=class_1_tensegrity_module_n_h_r(nbars,h0,r0*1./cos(pi/nbars),r0,theta0=pi/nbars)grid=tgls.ToyGLStructure()foriinrange(nx):print"Progress:",100.*i/nx,"%"forjinrange(ny):v0=[i*2*r0,j*2*r0,0]grid.add_structure_at(module4,v0)grid.save_for_toygl("TestTgl_grid.txt")