Python Forum
Trying to replace for loops with numpy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to replace for loops with numpy
#5
Thanks again for your reply!

You are correct, there are nodes and elements for each part. The floor is actually flat in the start, but it deflects. Also, the code is supposed to be flexible so it will work for different scenarios, thats why I'm using all elements even for the floor. I went back to the code one more time and I realized that the coordenates actualy come in a 1x3 format, bu are repeated 11 times for each different time step:

(output from python)
[[20.15 -7.75 -5.69]]

[[-68.92 -73.01 -25.47]]

This is an example of the first coordenate of the first and second part for the first time step. Then I use the equation:

dist = ((el2[t, 0] - el1[t, 0]) ** 2 + (el2[t, 1] - el1[t, 1]) ** 2 + (el2[t, 2] - el1[t, 2]) ** 2) ** (1 / 2)
Which will compute the distance between this two coordinates
Reply


Messages In This Thread
RE: Trying to replace for loops with numpy - by vspoloni - Jul-31-2019, 03:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 631 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,642 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  replace sets of values in an array without using loops paul18fr 7 1,762 Jun-20-2022, 08:15 PM
Last Post: paul18fr
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 3,007 Apr-09-2019, 04:54 PM
Last Post: PhysChem

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020