- Thank you received: 0
Max value of an array
6 years 1 month ago #1230
by noname
Max value of an array was created by noname
Hello everyone,
I am using Netgen to solve NS equations and at some point I am doing a time loop and in each time step keeping variables in an array. I have two questions, first, how can I save 2 variables in two columns of an array?? I want to save the time instant t in one column and the drag coefficient at that time instant at second column. Second question is that how can I find the max value of drag cofficient and the time it occured?
right now I am saving the time and drag coefficient seperately as..
drag_list = []
time_list = []
But i do not know how to find the max value of drag_list nor the instant it occured. Anyone knows how to solve this?
Thanks in advance
I am using Netgen to solve NS equations and at some point I am doing a time loop and in each time step keeping variables in an array. I have two questions, first, how can I save 2 variables in two columns of an array?? I want to save the time instant t in one column and the drag coefficient at that time instant at second column. Second question is that how can I find the max value of drag cofficient and the time it occured?
right now I am saving the time and drag coefficient seperately as..
drag_list = []
time_list = []
Code:
while(t < tfinal):
....
....
c_d=Integrate(drag,mesh)
drag_list.append(c_d)
time_list.append(t)
But i do not know how to find the max value of drag_list nor the instant it occured. Anyone knows how to solve this?
Thanks in advance
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
6 years 1 month ago #1235
by christopher
Replied by christopher on topic Max value of an array
Hi
Best
Christopher
Code:
index=drag_list.index(max(drag_list))
maxdrag, maxtime = drag_list[index], time_list[index]
Christopher
Time to create page: 0.093 seconds