如何编写测试数字序列的 if 语句:

How to write an if statements which test number sequence:

提问人:Munira Hadhrami 提问时间:6/6/2023 更新时间:6/6/2023 访问量:8

问:

在此处输入图像描述

我正在编写一个小代码,可以帮助将孔放置在 3 种不同的配置(生产者/黄色和注入器/蓝色),如所附原理图所示,即: 对于第 1 种配置(Producer 之后是 Injector),它非常简单:- 如果数字 % 2==1(奇数),则生产者,否则,如果偶数,则为喷油器。

如何为配置 2 和 3 做到这一点?生产者生产者喷油器(PPI)和生产者喷油器生产者(PIP)?

提前非常感谢,

                    for j in range(0,7*int(well_spacing/10),int(well_spacing/10)):
                           if well_config=='PIP':
                               if (number % 2 == 1): # odd number top of 1A
                                   if (prod_loc=='top1a'):
                                       k= 2 # producers in layer 2
                                   else: # (number % 2 == 1) and prod_loc=='mid1a': # odd number mid of 1A
                                       k= 4 # producers in layer 4
                               else:
                                   if (number % 2 != 1):  # even number
                                       if (inj_loc=='top1b'):
                                           k= 8  # inj in layer 4
                                       else: # (number % 2 != 1) and inj_loc=='belowowc': even number belowowc
                                           k= 18 # inj in layer 18
                           elif  well_config=='PPI':
                               if (number % 2 == 1):# odd number top of 1A
                                   if (prod_loc=='top1a'):
                                       k= 2 # producers in layer 2
                                   else:  # (number % 2 == 1) and prod_loc=='mid1a': # odd number mid of 1A  
                                       k= 4 # producers in layer 4
                               else:
                                   if (number % 2 != 1): 
                                       if (inj_loc=='top1b'):
                                           k= 8  # inj in layer 4
                                       else: # (number % 2 != 1) and inj_loc=='belowowc': even number belowowc
                                           k= 18 # inj in layer 18
                           elif  well_config=='PIP':
                                  if (number % 2 == 1): # odd number top of 1A
                                     if (prod_loc=='top1a'):   
                                          k= 2 # producers in layer 2
                                     else: # (number % 2 == 1) and prod_loc=='mid1a': # odd number mid of 1A
                                          k= 4 # producers in layer 4
                                  else:
                                       if (number % 2 != 1):
                                          if (inj_loc=='top1b'):
                                              k= 8  # inj in layer 4
                                          else: # (number % 2 != 1) and inj_loc=='belowowc': even number belowowc
                                              k= 18 # inj in layer 18                                
                           number += 1
                           i = int(well_spacing/10/2)
                           well_locations.append((i,j,k,int(well_length/10))
数字 序列

评论


答: 暂无答案