def _get_pattern(self): binding_x_size, binding_y_size = self.binding.shape x_col_size = self.x_colors.shape[0] y_col_size = self.y_colors.shape[0] x_size = lcm(x_col_size, binding_x_size) y_size = lcm(y_col_size, binding_y_size) pattern_data = np.empty((x_size, y_size, 3)) for k in xrange(x_size): for l in xrange(y_size): if self.binding[k % binding_x_size, l % binding_y_size]: color = self.x_colors[k % x_col_size] else: color = self.y_colors[l % y_col_size] pattern_data[k, l, :] = color return pattern_data
def RSAKeyGeneration(socket, option): while(True): p = secrets.randbits(256) if(util.is_prime(p)): break while(True): q = secrets.randbits(256) if(util.is_prime(q) and p!=q): break N = p*q carmichael = util.lcm(p-1,q-1) e = 65537 d = float(1+carmichael)/e k = 1 while(not d.is_integer()): d = float(1+k*carmichael)/e k += 1 d = int(d) socket.send(str(e).encode()) e = int(socket.recv(1024).decode()) socket.send(str(N).encode()) n = int(socket.recv(1024).decode()) return d, n, e, N
else: fea_config_dict['model_name_prefix'] = 'PS_Qr%d_%s' % ( fea_config_dict['Active_Qr'], fea_config_dict['Steel']) if fea_config_dict['DPNV'] == True: fea_config_dict['model_name_prefix'] += '_DPNV' if fea_config_dict['End_Ring_Resistance'] == 0: fea_config_dict['model_name_prefix'] += '_NoEndRing' if fea_config_dict['Restart'] == True: fea_config_dict['model_name_prefix'] += '_Restart' return fea_config_dict['model_name_prefix'] print build_model_name_prefix(fea_config_dict) # FEMM Static FEA fea_config_dict['femm_deg_per_step'] = 0.25 * (360 / 4) / utility.lcm( 24 / 4., fea_config_dict['Active_Qr'] / 4.) # at least half period # fea_config_dict['femm_deg_per_step'] = 1 * (360/4) / utility.lcm(24/4., fea_config_dict['Active_Qr']/4.) # at least half period # fea_config_dict['femm_deg_per_step'] = 0.1 #0.5 # deg print 'femm_deg_per_step is', fea_config_dict[ 'femm_deg_per_step'], 'deg (Qs=24, p=2)' # Debug # if os.path.exists('d:/femm42/PS_Qr32_NoEndRing_M19Gauge29_DPNV_1e3Hz'): # os.system('bash -c "rm -r /mnt/d/femm42/PS_Qr32_NoEndRing_M19Gauge29_DPNV_1e3Hz"') # if os.path.exists('d:/OneDrive - UW-Madison/c/pop/Tran2TSS_PS_Opti.txt'): # os.system('bash -c "mv /mnt/d/OneDrive\ -\ UW-Madison/c/pop/Tran2TSS_PS_Opti.txt /mnt/d/OneDrive\ -\ UW-Madison/c/pop/initial_design.txt"') ################################################################ # History ################################################################ # run_folder = r'run#100/' # no iron loss csv data but there are field data!