modified: anasen_fem/run.py
modified: anasen_fem/scalars.dat modified: anasen_fem/scalars.dat.names modified: anasen_fem/wires2d.sif modified: anasen_fem/wires_gmsh2d_bc.py included IC and hot needle to simulations
This commit is contained in:
parent
652b680fb9
commit
00c8a9378e
|
|
@ -18,4 +18,4 @@ while val<178.3+0.1:
|
||||||
|
|
||||||
val=val+17.83
|
val=val+17.83
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
break
|
||||||
|
|
@ -1 +1 @@
|
||||||
6.500000000000E+002
|
8.500000000000E+002
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ Metadata for SaveScalars file: ./scalars.dat
|
||||||
Elmer version: 26.1
|
Elmer version: 26.1
|
||||||
Elmer compilation date: 2026-03-15
|
Elmer compilation date: 2026-03-15
|
||||||
Solver input file: wires2d.sif
|
Solver input file: wires2d.sif
|
||||||
File started at: 2026/03/31 16:47:17
|
File started at: 2026/04/01 17:39:04
|
||||||
|
|
||||||
Variables in columns of matrix:
|
Variables in columns of matrix:
|
||||||
1: res: potential difference
|
1: res: potential difference
|
||||||
|
|
|
||||||
|
|
@ -84,20 +84,36 @@ Solver 4
|
||||||
Filename = "scalars.dat"
|
Filename = "scalars.dat"
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
Boundary Condition 1
|
Boundary Condition 1
|
||||||
|
Target Boundaries = 1
|
||||||
|
Potential = -200
|
||||||
|
Calculate Electric Force = True
|
||||||
|
End
|
||||||
|
|
||||||
|
Boundary Condition 2
|
||||||
|
Target Boundaries = 2
|
||||||
|
Potential = 150
|
||||||
|
Calculate Electric Force = True
|
||||||
|
End
|
||||||
|
|
||||||
|
Boundary Condition 3
|
||||||
|
Target Boundaries = 3
|
||||||
|
Potential = 250
|
||||||
|
Calculate Electric Force = True
|
||||||
|
End
|
||||||
|
|
||||||
|
Boundary Condition 4
|
||||||
Target Boundaries = 10
|
Target Boundaries = 10
|
||||||
Potential = 0
|
Potential = 0
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Boundary Condition 5
|
||||||
Boundary Condition 2
|
|
||||||
Target Boundaries = 20
|
Target Boundaries = 20
|
||||||
Potential = 650
|
Potential = 650
|
||||||
Calculate Electric Force = True
|
Calculate Electric Force = True
|
||||||
End
|
End
|
||||||
|
|
||||||
Boundary Condition 3
|
Boundary Condition 6
|
||||||
Target Boundaries = 30
|
Target Boundaries = 30
|
||||||
Potential = 0
|
Potential = 0
|
||||||
End
|
End
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import gmsh,sys
|
import gmsh,sys
|
||||||
|
|
||||||
|
# --- Configuration Flags ---
|
||||||
|
include_ic_wires = True
|
||||||
|
include_needle = True
|
||||||
|
|
||||||
gmsh.initialize()
|
gmsh.initialize()
|
||||||
gmsh.model.add("adaptive_mesh")
|
gmsh.model.add("adaptive_mesh")
|
||||||
gmsh.option.setNumber('General.NumThreads', 10)
|
gmsh.option.setNumber('General.NumThreads', 10)
|
||||||
|
|
@ -23,11 +27,26 @@ z_loc = float(sys.argv[1])
|
||||||
|
|
||||||
k=(2*np.pi/24.)
|
k=(2*np.pi/24.)
|
||||||
|
|
||||||
|
#1 needle, 24 ic1, 24 ic2, 48 guard wires, 24 anodes, 24 cathodes
|
||||||
|
|
||||||
|
#needle at plane 1 at -zmax/2
|
||||||
|
xarr_needle = np.array([0])
|
||||||
|
yarr_needle = np.array([0])
|
||||||
|
|
||||||
|
#ic1 wires, plane 1 at -zmax/2
|
||||||
|
ki=2*np.pi/24.
|
||||||
|
xarr_i11 = np.array([23 * np.cos(ki * i) for i in range(24)])
|
||||||
|
yarr_i11 = np.array([23 * np.sin(ki * i) for i in range(24)])
|
||||||
|
|
||||||
|
#ic1 wires, plane 1 at -zmax/2
|
||||||
|
xarr_i21 = np.array([23 * np.cos(ki * i + ki/2.0) for i in range(24)])
|
||||||
|
yarr_i21 = np.array([23 * np.sin(ki * i + ki/2.0) for i in range(24)])
|
||||||
|
|
||||||
#guard wires, plane 1 at -zmax/2
|
#guard wires, plane 1 at -zmax/2
|
||||||
kg=2*np.pi/24.
|
kg=2*np.pi/48.
|
||||||
offsetg = -4*kg + 2*kg - np.pi/24 #-pi/4
|
offsetg = -4*kg + 2*kg - np.pi/24 #-pi/4
|
||||||
xarrg_1 = np.array([32*np.cos(kg*i+offsetg) for i in np.arange(0,24)])
|
xarrg_1 = np.array([32*np.cos(kg*i+offsetg) for i in np.arange(0,48)])
|
||||||
yarrg_1 = np.array([32*np.sin(kg*i+offsetg) for i in np.arange(0,24)])
|
yarrg_1 = np.array([32*np.sin(kg*i+offsetg) for i in np.arange(0,48)])
|
||||||
|
|
||||||
#anodes, plane 1 at -zmax/2
|
#anodes, plane 1 at -zmax/2
|
||||||
k=-2*np.pi/24.
|
k=-2*np.pi/24.
|
||||||
|
|
@ -41,10 +60,22 @@ offsetc = -4*kc + 2*kc - np.pi/24 #-pi/4
|
||||||
xarrc_1 = np.array([42*np.cos(kc*i+offsetc) for i in np.arange(0,24)])
|
xarrc_1 = np.array([42*np.cos(kc*i+offsetc) for i in np.arange(0,24)])
|
||||||
yarrc_1 = np.array([42*np.sin(kc*i+offsetc) for i in np.arange(0,24)])
|
yarrc_1 = np.array([42*np.sin(kc*i+offsetc) for i in np.arange(0,24)])
|
||||||
|
|
||||||
|
#needle at plane 2 at zmax/2
|
||||||
|
xarr_needle_2 = np.array([0])
|
||||||
|
yarr_needle_2 = np.array([0])
|
||||||
|
|
||||||
|
# #ic1 wires, plane 2 at zmax/2
|
||||||
|
xarr_i12 = np.array([23 * np.cos(ki * i) for i in range(24)])
|
||||||
|
yarr_i12 = np.array([23 * np.sin(ki * i) for i in range(24)])
|
||||||
|
|
||||||
|
# #ic2 wires, plane 2 at zmax/2
|
||||||
|
xarr_i22 = np.array([23 * np.cos(ki * i + ki/2.0) for i in range(24)])
|
||||||
|
yarr_i22 = np.array([23 * np.sin(ki * i + ki/2.0) for i in range(24)])
|
||||||
|
|
||||||
#guard wires, plane 2 at +zmax/2
|
#guard wires, plane 2 at +zmax/2
|
||||||
offsetg = offsetg-3*kg
|
offsetg = offsetg-3*kg
|
||||||
xarrg_2 = np.array([32*np.cos(kg*i+offsetg) for i in np.arange(0,24)])
|
xarrg_2 = np.array([32*np.cos(kg*i+offsetg) for i in np.arange(0,48)])
|
||||||
yarrg_2 = np.array([32*np.sin(kg*i+offsetg) for i in np.arange(0,24)])
|
yarrg_2 = np.array([32*np.sin(kg*i+offsetg) for i in np.arange(0,48)])
|
||||||
|
|
||||||
#anodes, plane 2 at +zmax/2
|
#anodes, plane 2 at +zmax/2
|
||||||
offset = offset-3*k
|
offset = offset-3*k
|
||||||
|
|
@ -56,6 +87,15 @@ offsetc = offsetc-3*kc
|
||||||
xarrc_2 = np.array([42*np.cos(kc*i+offsetc) for i in np.arange(0,24)])
|
xarrc_2 = np.array([42*np.cos(kc*i+offsetc) for i in np.arange(0,24)])
|
||||||
yarrc_2 = np.array([42*np.sin(kc*i+offsetc) for i in np.arange(0,24)])
|
yarrc_2 = np.array([42*np.sin(kc*i+offsetc) for i in np.arange(0,24)])
|
||||||
|
|
||||||
|
direction_needle_x = xarr_needle_2 - xarr_needle
|
||||||
|
direction_needle_y = yarr_needle_2 - yarr_needle
|
||||||
|
|
||||||
|
direction_ic1_x = xarr_i12 - xarr_i11
|
||||||
|
direction_ic1_y = yarr_i12 - yarr_i11
|
||||||
|
|
||||||
|
direction_ic2_x = xarr_i22 - xarr_i21
|
||||||
|
direction_ic2_y = yarr_i22 - yarr_i21
|
||||||
|
|
||||||
direction_guard_x = xarrg_2 - xarrg_1
|
direction_guard_x = xarrg_2 - xarrg_1
|
||||||
direction_guard_y = yarrg_2 - yarrg_1
|
direction_guard_y = yarrg_2 - yarrg_1
|
||||||
|
|
||||||
|
|
@ -66,6 +106,13 @@ direction_cathodes_x = xarrc_2 - xarrc_1
|
||||||
direction_cathodes_y = yarrc_2 - yarrc_1
|
direction_cathodes_y = yarrc_2 - yarrc_1
|
||||||
|
|
||||||
t = (z_loc+178.3)/(2*178.3) #z=-178.3 is 0, z=+178.3 is 1
|
t = (z_loc+178.3)/(2*178.3) #z=-178.3 is 0, z=+178.3 is 1
|
||||||
|
|
||||||
|
xloc_needle = xarr_needle + t*direction_needle_x
|
||||||
|
yloc_needle = yarr_needle + t*direction_needle_y
|
||||||
|
xloc_i1 = xarr_i11 + t*direction_ic1_x
|
||||||
|
yloc_i1 = yarr_i11 + t*direction_ic1_y
|
||||||
|
xloc_i2 = xarr_i21 + t*direction_ic2_x
|
||||||
|
yloc_i2 = yarr_i21 + t*direction_ic2_y
|
||||||
xloc_g = xarrg_1 + t*direction_guard_x
|
xloc_g = xarrg_1 + t*direction_guard_x
|
||||||
yloc_g = yarrg_1 + t*direction_guard_y
|
yloc_g = yarrg_1 + t*direction_guard_y
|
||||||
xloc_a = xarra_1 + t*direction_anodes_x
|
xloc_a = xarra_1 + t*direction_anodes_x
|
||||||
|
|
@ -77,23 +124,44 @@ yloc_c = yarrc_1 + t*direction_cathodes_y
|
||||||
# wire_radius_c = 0.0762 #mm
|
# wire_radius_c = 0.0762 #mm
|
||||||
# wire_radius_g = 0.0762 #mm
|
# wire_radius_g = 0.0762 #mm
|
||||||
wire_radius = 0.254 #mm
|
wire_radius = 0.254 #mm
|
||||||
|
needle=[]
|
||||||
|
ic1_wires = []
|
||||||
|
ic2_wires = []
|
||||||
guard_wires = []
|
guard_wires = []
|
||||||
anode_wires = []
|
anode_wires = []
|
||||||
cathode_wires = []
|
cathode_wires = []
|
||||||
gw_tags = [(3,i+24) for i in range(24)]
|
iw1_tags = [(3,i) for i in range(24)]
|
||||||
|
iw2_tags = [(3,i+24) for i in range(24)]
|
||||||
|
gw_tags = [(3,i+48) for i in range(48)]
|
||||||
aw_tags = [(3,i) for i in range(24)]
|
aw_tags = [(3,i) for i in range(24)]
|
||||||
cw_tags = [(3,i+24) for i in range(24)]
|
cw_tags = [(3,i+24) for i in range(24)]
|
||||||
|
|
||||||
#for i,[xa,ya,xc,yc] in enumerate(zip(xarra_1,yarra_1,xarrc_1,yarrc_1)):
|
#for i,[xa,ya,xc,yc] in enumerate(zip(xarra_1,yarra_1,xarrc_1,yarrc_1)):
|
||||||
for i,[xg,yg,xa,ya,xc,yc] in enumerate(zip(xloc_g,yloc_g,xloc_a,yloc_a,xloc_c,yloc_c)):
|
#create Hot Needle (1 total)
|
||||||
print(i,xg,yg,-178.3,xa,ya,-178.3,xc,yc,-178.3)
|
for i, (xn, yn) in enumerate(zip(xloc_needle, yloc_needle)):
|
||||||
gdisk = gmsh.model.occ.addDisk(xg,yg,0,wire_radius,wire_radius)
|
if include_needle:
|
||||||
adisk = gmsh.model.occ.addDisk(xa,ya,0,wire_radius,wire_radius)
|
ndisk = gmsh.model.occ.addDisk(xn, yn, 0, wire_radius, wire_radius)
|
||||||
cdisk = gmsh.model.occ.addDisk(xc,yc,0,wire_radius,wire_radius)
|
needle.append(ndisk)
|
||||||
|
|
||||||
|
#create Guard Wires (48 total)
|
||||||
|
for i, (xg, yg) in enumerate(zip(xloc_g, yloc_g)):
|
||||||
|
gdisk = gmsh.model.occ.addDisk(xg, yg, 0, wire_radius, wire_radius)
|
||||||
guard_wires.append(gdisk)
|
guard_wires.append(gdisk)
|
||||||
|
|
||||||
|
#create IC Anode and Cathode Wires (24 total each)
|
||||||
|
for i, (xa, ya, xc, yc) in enumerate(zip(xloc_a, yloc_a, xloc_c, yloc_c)):
|
||||||
|
adisk = gmsh.model.occ.addDisk(xa, ya, 0, wire_radius, wire_radius)
|
||||||
|
cdisk = gmsh.model.occ.addDisk(xc, yc, 0, wire_radius, wire_radius)
|
||||||
anode_wires.append(adisk)
|
anode_wires.append(adisk)
|
||||||
cathode_wires.append(cdisk)
|
cathode_wires.append(cdisk)
|
||||||
|
|
||||||
|
# Place IC wires only if flag is True
|
||||||
|
if include_ic_wires:
|
||||||
|
i1disk = gmsh.model.occ.addDisk(xloc_i1[i], yloc_i1[i], 0, wire_radius, wire_radius)
|
||||||
|
i2disk = gmsh.model.occ.addDisk(xloc_i2[i], yloc_i2[i], 0, wire_radius, wire_radius)
|
||||||
|
ic1_wires.append(i1disk)
|
||||||
|
ic2_wires.append(i2disk)
|
||||||
|
|
||||||
anasen_barrel = gmsh.model.occ.addDisk(0,0,0,500,500)
|
anasen_barrel = gmsh.model.occ.addDisk(0,0,0,500,500)
|
||||||
#gmsh.model.occ.synchronize()
|
#gmsh.model.occ.synchronize()
|
||||||
#gmsh.model.mesh.embed(1,anode_wires+cathode_wires,2,anasen_barrel)
|
#gmsh.model.mesh.embed(1,anode_wires+cathode_wires,2,anasen_barrel)
|
||||||
|
|
@ -102,50 +170,54 @@ gmsh.option.setNumber("Geometry.Tolerance", 1e-6)
|
||||||
gmsh.option.setNumber("Geometry.OCCFixDegenerated", 1)
|
gmsh.option.setNumber("Geometry.OCCFixDegenerated", 1)
|
||||||
gmsh.model.occ.synchronize()
|
gmsh.model.occ.synchronize()
|
||||||
|
|
||||||
gwire_surfs = []
|
# --- Surface Extraction ---
|
||||||
for w in guard_wires:
|
def get_surfs(disks):
|
||||||
gwire_surfs += [s[1] for s in gmsh.model.getBoundary([(2,w)], oriented=False) if s[0] == 1]
|
surfs = []
|
||||||
|
for d in disks:
|
||||||
|
surfs += [s[1] for s in gmsh.model.getBoundary([(2,d)], oriented=False) if s[0] == 1]
|
||||||
|
return surfs
|
||||||
|
|
||||||
awire_surfs = []
|
needle_surfs = get_surfs(needle) if include_needle else []
|
||||||
for w in anode_wires:
|
gwire_surfs = get_surfs(guard_wires)
|
||||||
awire_surfs += [s[1] for s in gmsh.model.getBoundary([(2,w)], oriented=False) if s[0] == 1]
|
awire_surfs = get_surfs(anode_wires)
|
||||||
|
cwire_surfs = get_surfs(cathode_wires)
|
||||||
cwire_surfs = []
|
i1wire_surfs = get_surfs(ic1_wires) if include_ic_wires else []
|
||||||
for w in cathode_wires:
|
i2wire_surfs = get_surfs(ic2_wires) if include_ic_wires else []
|
||||||
cwire_surfs += [s[1] for s in gmsh.model.getBoundary([(2,w)], oriented=False) if s[0] == 1]
|
|
||||||
gmsh.model.mesh.embed(1,cwire_surfs+awire_surfs+gwire_surfs,2,anasen_barrel)
|
|
||||||
|
|
||||||
for s in gmsh.model.getBoundary([(2,w)],oriented=False):
|
|
||||||
if s[0] == 1:
|
|
||||||
anasen_bdry=s[1]
|
|
||||||
|
|
||||||
|
|
||||||
f1 = gmsh.model.mesh.field.add("Distance")
|
all_active_wire_surfs = needle_surfs + gwire_surfs + awire_surfs + cwire_surfs + i1wire_surfs + i2wire_surfs
|
||||||
gmsh.model.mesh.field.setNumbers(f1,"CurvesList",cwire_surfs+awire_surfs+gwire_surfs)
|
gmsh.model.mesh.embed(1, all_active_wire_surfs, 2, anasen_barrel)
|
||||||
|
|
||||||
f2 = gmsh.model.mesh.field.add("Threshold")
|
# f1 = gmsh.model.mesh.field.add("Distance")
|
||||||
gmsh.model.mesh.field.setNumber(f2,"InField",f1)
|
# gmsh.model.mesh.field.setNumbers(f1, "CurvesList", all_active_wire_surfs)
|
||||||
gmsh.model.mesh.field.setNumber(f2,"SizeMin",0.1)
|
|
||||||
gmsh.model.mesh.field.setNumber(f2,"SizeMax",5)
|
|
||||||
gmsh.model.mesh.field.setNumber(f2,"DistMin",1)
|
|
||||||
gmsh.model.mesh.field.setNumber(f2,"DistMax",20)
|
|
||||||
|
|
||||||
gmsh.model.mesh.field.setAsBackgroundMesh(f2)
|
# f2 = gmsh.model.mesh.field.add("Threshold")
|
||||||
|
# gmsh.model.mesh.field.setNumber(f2, "InField", f1)
|
||||||
|
# gmsh.model.mesh.field.setNumber(f2, "SizeMin", 0.1) # Fine mesh near wires
|
||||||
|
# gmsh.model.mesh.field.setNumber(f2, "SizeMax", 10.0) # Large mesh in empty space
|
||||||
|
# gmsh.model.mesh.field.setNumber(f2, "DistMin", 1.0) # Apply SizeMin within 1mm
|
||||||
|
# gmsh.model.mesh.field.setNumber(f2, "DistMax", 20.0) # Transition to SizeMax by 20mm
|
||||||
|
|
||||||
gmsh.model.addPhysicalGroup(1, gwire_surfs, tag=10)
|
# gmsh.model.mesh.field.setAsBackgroundMesh(f2)
|
||||||
gmsh.model.setPhysicalName(1,10,"guard_wires")
|
|
||||||
|
|
||||||
gmsh.model.addPhysicalGroup(1, awire_surfs, tag=20)
|
|
||||||
gmsh.model.setPhysicalName(1,20,"anode_wires")
|
|
||||||
|
|
||||||
gmsh.model.addPhysicalGroup(1, cwire_surfs, tag=30)
|
# --- Physical Groups ---
|
||||||
gmsh.model.setPhysicalName(1,30,"cathode_wires")
|
# Needle
|
||||||
|
if include_needle:
|
||||||
|
gmsh.model.addPhysicalGroup(1, needle_surfs, tag=1, name="hot_needle")
|
||||||
|
|
||||||
#gmsh.model.addPhysicalGroup(1, [anasen_bdry], tag=30)
|
# IC Wires
|
||||||
#gmsh.model.setPhysicalName(1,30,"barrel_boundary")
|
if include_ic_wires:
|
||||||
|
gmsh.model.addPhysicalGroup(1, i1wire_surfs, tag=2, name="ic_wire_1")
|
||||||
|
gmsh.model.addPhysicalGroup(1, i2wire_surfs, tag=3, name="ic_wire_2")
|
||||||
|
|
||||||
gmsh.model.addPhysicalGroup(2,[anasen_barrel],tag=13)
|
# Proportional Counter Wires
|
||||||
gmsh.model.setPhysicalName(1,13,"gas")
|
gmsh.model.addPhysicalGroup(1, gwire_surfs, tag=10, name="guard_wires")
|
||||||
|
gmsh.model.addPhysicalGroup(1, awire_surfs, tag=20, name="anode_wires")
|
||||||
|
gmsh.model.addPhysicalGroup(1, cwire_surfs, tag=30, name="cathode_wires")
|
||||||
|
|
||||||
|
# Gas Volume (2D)
|
||||||
|
gmsh.model.addPhysicalGroup(2, [anasen_barrel], tag=13, name="gas")
|
||||||
|
|
||||||
gmsh.option.setNumber("Mesh.Algorithm", 6)
|
gmsh.option.setNumber("Mesh.Algorithm", 6)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user