Example #1
0
def fitness(S):
    # first the yield
    marks = 0
    A=st.node_eq_mat(S) # matrix for bar tension
    
    if np.linalg.det(A) == 0: #if the matrix is not invesable say it is a shit structure
        return (0,0,100)
    B = np.linalg.inv(A) #linear alg for A x (tens|R) = Force
    utension = np.dot(B,action_vect(S))#THIS IS THE ACTION VECTOR FOR THE MOMENT 
    uextension = st.ext_vec(simdata.E,simdata.barref,S,utension)

    reactions=3

    Yield= tens_yield_check(S,utension)# Basic braking yield

    #displacement yield
    normtens=list(utension)
    
    for i in xrange(reactions):# getting rid of reactions
        normtens.pop()
    normtens =np.array(normtens)
    n1yield= VW_node1(normtens,uextension,simdata.n1disp,S) #%%timeit =30.8 µs

    #colision Yield

    C=st.node_disp_mat(S) #matrix of node displacements
    if np.linalg.det(C) == 0: #if the matrix is not invesable say it is a shit structure
        return (0,0,100)
    D=np.linalg.inv(C) # solving the  C x dipvars = Evect system
    dispv = np.dot(D,uextension)
    delta= st.listdipslacements(S,dispv)
    cyield= col_yield_check(S,simdata.minP,simdata.maxP,delta)

    
    optyield= abs(simdata.convyield - Yield)/simdata.convyield

    if cyield != 'No colision': #avoid out putting 0 if the cyield is False
        primitiveyield= min([Yield,n1yield,cyield])
    else:
        primitiveyield= min([Yield,n1yield])
    #now the categorization
    
    if primitiveyield <= 8500:
        marks =0
    elif n1yield <= 8500 and Yield > 8500 and cyield > 8500:
        marks =3
    elif primitiveyield > 8500 and Yield < 12000:
        marks = 5
    elif Yield> 12000 :
        marks =7
    else:
        pass
    return (Yield,marks,optyield)
Example #2
0
Yield= rt.tens_yield_check(S,utension)

#displacement yield
normtens=list(utension)
for i in xrange(reactions): #keeping only the bars
    normtens.pop()
nomtens=np.array(normtens)

n1yield= rt.VW_node1(normtens,uextension,simdata.n1disp,S) #%%timeit =30.8 µs

#colision Yield

C=st.node_disp_mat(S) #matrix of node displacements
D=np.linalg.inv(C) # solving the  C x dipvars = Evect system
dispv = np.dot(D,uextension)
delta= st.listdipslacements(S,dispv)

cyield= rt.col_yield_check(S,simdata.minP,simdata.maxP,delta)
#Yield assesment 

print 'This structure yields because:'
print 'It breaks at : ' + str(Yield) +' N'
print 'It displaces 3mm after : ' + str(n1yield) +' N'
print 'It collides with an obstacle at ' + str(cyield) + ' N'
print 'Overall it yields at: ' + str(min([Yield, n1yield,cyield])) + ' N'

print time.clock() - t
##%%timeit = 1ms , not bad :[
def mod_graph(G):
    bars = st.varlist(G)
    for i in xrange(reactions):