def saveCurrentsCentroids(params_simu, simuDirName): my_id = 0 tmpDirName = os.path.join(simuDirName, 'tmp' + str(my_id)) geoDirName = os.path.join(simuDirName, 'geo') if (my_id == 0): target_mesh = MeshClass(geoDirName, params_simu.targetName, params_simu.targetDimensions_scaling_factor, params_simu.z_offset, params_simu.languageForMeshConstruction, params_simu.meshFormat, params_simu.meshFileTermination) # target_mesh.constructFromGmshFile() target_mesh.constructFromSavedArrays(os.path.join(tmpDirName, "mesh")) SAVE_CURRENTS_CENTROIDS = (params_simu.SAVE_CURRENTS_CENTROIDS and (params_simu.BISTATIC == 1)) if SAVE_CURRENTS_CENTROIDS: print("............saving currents at centroids of triangles") nbTimeSteps = 1 I_coeff = read1DBlitzArrayFromDisk( os.path.join(tmpDirName, 'ZI/ZI.txt'), 'F') J_centroids_triangles = JMCentroidsTriangles(I_coeff, target_mesh) write_VectorFieldTrianglesCentroids( os.path.join(simuDirName, 'result', 'J_centroids_triangles.txt'), J_centroids_triangles, target_mesh) print( "............end of saving of currents. Located in result directory." )
def computeCurrentsVisualization(params_simu, variables, simuDirName): my_id = 0 tmpDirName = os.path.join(simuDirName, 'tmp' + str(my_id)) geoDirName = os.path.join(simuDirName, 'geo') if (my_id == 0): target_mesh = MeshClass(geoDirName, params_simu.targetName, params_simu.targetDimensions_scaling_factor, params_simu.z_offset, params_simu.languageForMeshConstruction, params_simu.meshFormat, params_simu.meshFileTermination) # target_mesh.constructFromGmshFile() target_mesh.constructFromSavedArrays(os.path.join(tmpDirName, "mesh")) N_RWG = readIntFromDisk(os.path.join(tmpDirName, "mesh", "N_RWG.txt")) CURRENTS_VISUALIZATION = params_simu.CURRENTS_VISUALIZATION and (N_RWG<2e6) and (params_simu.BISTATIC == 1) if CURRENTS_VISUALIZATION: print("............Constructing visualisation of currents") if (N_RWG<5e4): nbTimeSteps = 48 else: nbTimeSteps = 1 I_coeff = read1DBlitzArrayFromDisk(os.path.join(tmpDirName, 'ZI/ZI.txt'), 'F') J_centroids_triangles = JMCentroidsTriangles(I_coeff, target_mesh) norm_J_centroids_triangles = normJMCentroidsTriangles(J_centroids_triangles) norm_J_centroids_triangles_timeDomain = normJMCentroidsTriangles_timeDomain(J_centroids_triangles, variables['w'], nbTimeSteps) write_VectorFieldTrianglesCentroidsGMSH(os.path.join(simuDirName, 'result', params_simu.targetName) + '.J_centroids_triangles.pos', real(J_centroids_triangles), target_mesh) write_ScalarFieldTrianglesCentroidsGMSH(os.path.join(simuDirName, 'result', params_simu.targetName) + '.norm_J_centroids_triangles_timeDomain.pos', norm_J_centroids_triangles_timeDomain, target_mesh) write_ScalarFieldTrianglesCentroidsGMSH(os.path.join(simuDirName, 'result', params_simu.targetName) + '.norm_J_centroids_triangles.pos', norm_J_centroids_triangles, target_mesh) print("............end of currents visualisation construction. Open with gmsh the *.pos files in result directory.") else: "Error in the computeCurrentsVisualization routine. Probably you required currents visualization computation for a mesh too big" sys.exit(1)
if __name__=="__main__": path = './geo' targetName = 'sphere' f = 2.12e9 write_geo(path, targetName, 'lc', c/f/9.1) write_geo(path, targetName, 'lx', 0.1) write_geo(path, targetName, 'ly', 0.1) write_geo(path, targetName, 'lz', 0.1) executeGmsh(path, targetName, 0) z_offset = 0.0 targetDimensions_scaling_factor = 1.0 languageForMeshConstruction = "Python" meshFormat = 'GMSH' meshFileTermination = '.msh' target_mesh = MeshClass(path, targetName, targetDimensions_scaling_factor, z_offset, languageForMeshConstruction, meshFormat, meshFileTermination) target_mesh.constructFromGmshFile() N_RWG = target_mesh.N_RWG w = 2. * pi * f eps_r = 1. mu_r = 1. TDS_APPROX = 0 Z_s = 0.0 list_of_test_edges_numbers = arange(N_RWG).astype('i') list_of_src_edges_numbers = arange(N_RWG).astype('i') CFIE = array([0, 0, 0, 1], 'D') signSurfObs, signSurfSrc = 1.0, 1.0 t0 = time.clock() MOM_FULL_PRECISION = 1 Z_CFIE_J, Z_CFIE_M = Z_CFIE_MoM(CFIE, list_of_test_edges_numbers, list_of_src_edges_numbers, target_mesh.RWGNumber_CFIE_OK, target_mesh.RWGNumber_M_CURRENT_OK, target_mesh.RWGNumber_signedTriangles, target_mesh.RWGNumber_edgeVertexes, target_mesh.RWGNumber_oppVertexes, target_mesh.vertexes_coord, w, eps_r, mu_r, signSurfObs, signSurfSrc, TDS_APPROX, Z_s, MOM_FULL_PRECISION)
# especially for order 5.5, a = 0.3, for which f = 1487993627.3926289, tol = 1e-3 # However, Frob-CFIE convergence is more than OK: it is guaranteed f = .5e9 fileName = targetName write_geo(path, fileName, 'lc', c / f / 10.) write_geo(path, fileName, 'lx', 0.1) write_geo(path, fileName, 'ly', 0.1) write_geo(path, fileName, 'lz', 0.1) executeGmsh(path, targetName, 0) z_offset = 0.0 targetDimensions_scaling_factor = 1.0 languageForMeshConstruction = "C++" meshFormat = 'GMSH' meshFileTermination = '.msh' target_mesh = MeshClass(path, targetName, targetDimensions_scaling_factor, z_offset, languageForMeshConstruction, meshFormat, meshFileTermination) target_mesh.constructFromGmshFile() N_RWG = target_mesh.N_RWG print("average RWG length = " + str(target_mesh.average_RWG_length) + "m = lambda /" + str((c / f) / target_mesh.average_RWG_length)) print() w = 2. * pi * f eps_r = 1. mu_r = 1. TDS_APPROX = 0 Z_s = 0.0 J_dip = array([1.0, 1.0, 0.], 'D') r_dip = array([0.1, 0.1, 2.0], 'd') list_of_test_edges_numbers = arange(N_RWG, dtype='i') list_of_src_edges_numbers = arange(N_RWG, dtype='i')