How to overwrite an array with equal values from another array?

Hello!

I am working on a civil engineering project and would like some help if possible. I have a building which has hundreds of lines and hundreds of points what represent the start and end of the lines. Each point line is placed in an array that gives the index of node i and indexof node j. Now I have another array identifying a smaller number of the same edges, but need to assign a new area for these edges. What I have done is the following:

A_beam = 0.008301 #(m^2)
A_hscolumn = 0.141211 #(m^2)
A_nscolumn = 0.140000 #(m^2)
Areas = A_beam*np.ones([len(members)]) #Initialise all member areas to beam area

for n, mbr in enumerate(members):
   if compositeCols.any() == members.any():
        Areas[n] = A_hscolumn
        
#for n, mbr in enumerate(members):
    #if(pins[n,0]==0 and pins[n,1]==0):
        #Areas[n] = A_bar #Assign bar member area

print(Areas)

So I need to access the members array and check if there are any edges from composite array, and if they do repeat then assign the A_hscolumn area to it. How can I go about this?

Thank you for your help!

I’m not sure I understand …

I’ll take a guess:

  1. Check whether something in the members list is also in the composite list.
  2. If it is, replace that value in the members array with the number in variable A_hscolumn .

I’d do the iteration using the index:

for i in range(len(members)): 
  if members[i] in composite: 
    members[i] = A_hscolumn
1 Like

Hi!
Thank you, but no what this function did was just assign the A_hscolumn area to all edges. So I have two sets of CSV files, members which has all the edges represented by the index for point i and point j. Then there is another CSV with edges some selected edges from the same model, compositeCols. The main goal is to assign different section areas to these selected edges from compositeCols. So what I tried was creating a bucket (Areas) where all the areas are the small area A_beam. Now what I have been trying is to say "for every edge in members that repeats in compositeCols, change the area in Areas for that particular repeating edge. How can I proceed with this?

Thank you!

Your question is very difficult to follow. From both of your posts, @janbazant1107978602’s solution seems to do what you’re asking. Perhaps a small sample of your data would help us to see what exactly you’re trying to do. If you could show a sample of the data in each of the lists, and what you want the output to look like, someone may be able to help.

So this is what I managed to do:

memberType = [] #Initialise a list to hold the member types (beam or column)
Areas = np.zeros([len(members)]) #An array to hold individual area for each member
#gamma = np.zeros([len(members)]) #An array to hold individual mass per unit length for each member

for n,m in enumerate(members):
    #Initially assume all members are bars 
    memberType.append('b')
    Areas[n] = A_beam
#   gamma[n] = gammaSteel
    
    #Check if member is a composite member
    for c in compositeCols:
        if(m[0] in c and m[1] in c):
            memberType[n] = 'c'
            Areas[n] = A_hscolumn
#           gamma[n] = gammaC

Two nested for loops and this checks for which elements are columns repeating inside the members array and done it finally assigns the areas to the respective elements

Thank you for your help!