Skip to content
Snippets Groups Projects
Commit 50dd2625 authored by Matteo Cicuttin's avatar Matteo Cicuttin
Browse files

Updated examples.

parent 15378f6e
No related branches found
No related tags found
No related merge requests found
--[[
This example is a simplified version of a more complicated model
of an electrostatic discharge applied to a metallic box.
The discharge is modeled as a surface current source, but this is
not physically correct. This model is more a test for interface
BCs and sources than anything else.
--]]
sim.name = "binde_simplified" -- simulation name sim.name = "binde_simplified" -- simulation name
sim.dt = 1e-11 -- timestep size sim.dt = 1e-11 -- timestep size
sim.timesteps = 10000 -- num of iterations sim.timesteps = 10000 -- num of iterations
...@@ -8,6 +15,8 @@ sim.approx_order = 1 -- approximation order ...@@ -8,6 +15,8 @@ sim.approx_order = 1 -- approximation order
postpro.silo_output_rate = 10 -- rate at which to write silo files postpro.silo_output_rate = 10 -- rate at which to write silo files
postpro.cycle_print_rate = 10 -- console print rate postpro.cycle_print_rate = 10 -- console print rate
sim.time_integrator = "leapfrog" -- use leapfrog with dissipative materials
-- ** Materials ** -- ** Materials **
-- Aluminum -- Aluminum
local alu = {2} local alu = {2}
...@@ -16,11 +25,6 @@ for i,v in ipairs(alu) do ...@@ -16,11 +25,6 @@ for i,v in ipairs(alu) do
materials[v].epsilon = 1 materials[v].epsilon = 1
materials[v].mu = 1 materials[v].mu = 1
materials[v].sigma = 1 materials[v].sigma = 1
local coeff = sim.dt*materials[v].sigma/(materials[v].epsilon*const.eps0)
if math.abs(1-coeff) > 1 then
print("WARNING: sigma too high on domain " .. v .. ", this simulation is going to explode")
end
end end
local air = {3} local air = {3}
...@@ -38,14 +42,17 @@ for i,v in ipairs(Z_bnds) do ...@@ -38,14 +42,17 @@ for i,v in ipairs(Z_bnds) do
bndconds[v].kind = "impedance" bndconds[v].kind = "impedance"
end end
-- Linear interpolation
function interp(t, t0, t1, y0, y1) function interp(t, t0, t1, y0, y1)
return (t-t0)*(y1-y0)/(t1-t0) + y0 return (t-t0)*(y1-y0)/(t1-t0) + y0
end end
-- Shape of the electrostatic discharge given as time-value pairs
local current_shape = { {0, 0}, {9.5e-9, 0.03}, {1.1e-8, 1}, local current_shape = { {0, 0}, {9.5e-9, 0.03}, {1.1e-8, 1},
{1.4e-8, 0.45}, {1.6e-8, 0.45}, {2.7e-8, 0.6}, {1.4e-8, 0.45}, {1.6e-8, 0.45}, {2.7e-8, 0.6},
{9e-8, 0.01}, {1e-7, 0} } {9e-8, 0.01}, {1e-7, 0} }
-- Function that evaluates the source
function interface_source_7(tag, x, y, z, t) function interface_source_7(tag, x, y, z, t)
for ii = 1,(#current_shape-1) do for ii = 1,(#current_shape-1) do
local t0 = current_shape[ii][1] local t0 = current_shape[ii][1]
...@@ -60,15 +67,10 @@ function interface_source_7(tag, x, y, z, t) ...@@ -60,15 +67,10 @@ function interface_source_7(tag, x, y, z, t)
return 0, 0, 0 return 0, 0, 0
end end
-- Surface current interface condition
local discharge_surf = 7 local discharge_surf = 7
ifaceconds[discharge_surf] = {} ifaceconds[discharge_surf] = {}
ifaceconds[discharge_surf].kind = "surface_current" ifaceconds[discharge_surf].kind = "surface_current"
ifaceconds[discharge_surf].source = interface_source_7 ifaceconds[discharge_surf].source = interface_source_7
function on_timestep(ts)
--local time = ts*sim.dt
--local curr = interface_source_7(0,0,0,0,time)
--print("Time: " .. time .. ", current: " .. curr)
end
--[[
This example simulates a modal converter at 15.5 GHz.
]]--
sim.name = "modeconv" -- simulation name sim.name = "modeconv" -- simulation name
sim.dt = 1e-14 -- timestep size sim.dt = 1e-14 -- timestep size
sim.timesteps = 50000 -- num of iterations sim.timesteps = 50000 -- num of iterations
......
--[[
Model of a 3-element yagi antenna receiving a plane wave at 300 MHz
]]--
sim.name = "yagi" -- simulation name sim.name = "yagi" -- simulation name
sim.dt = 1e-12 -- timestep size sim.dt = 1e-12 -- timestep size
sim.timesteps = 2000 -- num of iterations sim.timesteps = 2000 -- num of iterations
...@@ -15,12 +18,7 @@ for i,v in ipairs(alu) do ...@@ -15,12 +18,7 @@ for i,v in ipairs(alu) do
materials[v] = {} materials[v] = {}
materials[v].epsilon = 1 materials[v].epsilon = 1
materials[v].mu = 1 materials[v].mu = 1
materials[v].sigma = 17 materials[v].sigma = 3.69e7
local coeff = sim.dt*materials[v].sigma/(materials[v].epsilon*const.eps0)
if math.abs(1-coeff) > 1 then
print("WARNING: sigma too high on domain " .. v .. ", this simulation is going to explode")
end
end end
local air = {5} local air = {5}
......
--[[
Model of a 3-element Yagi antenna radiating at 300 MHz.
The source is modeled as a volumetric current between the
two halves of the radiator.
--]]
sim.name = "yagi_rad" -- simulation name
sim.dt = 1e-13 -- timestep size
sim.timesteps = 50000 -- num of iterations
sim.gmsh_model = "yagi_rad.geo" -- gmsh model filename
sim.use_gpu = 1 -- 0: cpu, 1: gpu
sim.approx_order = 2 -- approximation order
--sim_geom_order = 1 -- geometric order, only 1 for now
sim.time_integrator = "leapfrog"
postpro.silo_output_rate = 500 -- rate at which to write silo files
postpro.cycle_print_rate = 10 -- console print rate
postpro["H"].silo_mode = "none"
postpro["J"].silo_mode = "zonal"
-- ** Materials **
-- Aluminum
local alu = {2, 3, 6, 8}
for i,v in ipairs(alu) do
materials[v] = {}
materials[v].epsilon = 1
materials[v].mu = 1
materials[v].sigma = 3.69e7
end
local air = {4, 7}
for i,v in ipairs(air) do
materials[v] = {}
materials[v].epsilon = 1
materials[v].mu = 1
materials[v].sigma = 0
end
-- ** Boundary conditions **
local Z_bnds = { 17 }
for i,v in ipairs(Z_bnds) do
bndconds[v] = {}
bndconds[v].kind = "impedance"
end
local freq = 3e8
function source(tag, x, y, z, t)
local Ex = 0
local Ey = 0
local Ez = math.sin(2*math.pi*t*freq)
return Ex, Ey, Ez
end
-- Apply the source to subdomain with tag 4
sources[4] = source
enable_boundary_sources(false)
enable_interface_sources(false)
SetFactory("OpenCASCADE");
Mesh.MeshSizeFromCurvature = 5;
Mesh.MeshSizeMax=0.4;
spradius = 3;
MHz = 300;
ER = 0.005;
R = 0.5*(300/MHz);
A = 0.44*(300/MHz);
D = 0.43*(300/MHz);
sp_RA = 0.25*(300/MHz);
sp_AD = 0.13*(300/MHz);
src = A/20;
Ax = (A-src)/2;
Sphere(1) = {0, 0, 0, spradius, -Pi/2, Pi/2, 2*Pi};
Cylinder(2) = {-sp_RA, 0, -R/2, 0, 0, R, ER, 2*Pi};
Cylinder(3) = {0, 0, src/2, 0, 0, Ax, ER, 2*Pi};
Cylinder(4) = {0, 0, -src/2, 0, 0, src, ER, 2*Pi};
Cylinder(5) = {0, 0, src/2-Ax, 0, 0, Ax, ER, 2*Pi};
Cylinder(6) = {sp_AD, 0, -D/2, 0, 0, D, ER, 2*Pi};
Coherence;
//MeshSize { Volume{2} } = 0.01;
//MeshSize {15,16,17,18,19,20,21,22} = 0.1;
//+
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment