Example #1
0
from mpi4py import MPI

from yafdtd import source

from yafdtd.grid import String
from yafdtd.utils import *

comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()

# host = commands.getoutput("hostname")
# print "I am process " + str(rank) + " of " + str(size) + " on " + host

cells = 30
string = String(30/size)
print "cells: %s" % cells
print "size: %s"% size

left = 0.0
right = 0.0

for t in range(0,1000):
    update_efield(string)
    
    comm.Barrier()
    
    if rank > 0:
        string.efield[0] = string.efield[0] + 0.5 * ( left - string.hfield[0] )

    comm.Barrier()
Example #2
0
sys.path.append(".")

from yafdtd import source
from yafdtd.grid import String
from yafdtd.utils import *
from scipy.constants import c, epsilon_0

dt = 10**-9
dx = dt*c*2
f  = dt * (10**16)

name = "oned-test"
outdir = "result/%s" % name
prepare(outdir)

string = String(31)
string.source = source.HardSource(source.sin_oft, (f,), string.shape[0]/2)

hdf5 = h5py.File("%s/%s.hdf5" % (outdir, name),"w")
hdf5.attrs["name"]  = name
hdf5.attrs["dt"]    = dt
hdf5.attrs["dx"]    = dx
hdf5.require_group("timeline")

for t in range(0,300):
    string.update_dfield()
    string.update_efield()
    string.update_abc()
    # string.update_source(t*dt)
    string.efield[15] = source.sin_oft(t*dt, f)
    string.update_bfield()
Example #3
0
#!/usr/bin/env python
#-*- mode: python -*-

import sys, os, csv, re, shutil, h5py, pylab
sys.path.append(".")

from yafdtd.source import *
from yafdtd.grid import String
from yafdtd.utils import *
from scipy.constants import c, epsilon_0
from math import pi, sin, cos
from sys import stdout

string1 = String(201)
string1.enter = 5

string2 = String(201)
string2.enter = 5

for t in range(1200):
    stdout.write("\b"*80+str(t))

    # string1.update(sin(2*pi*0.025*t))

    # string1.update(gaussian(t, 200, 60))
    string2.update(cos(2*pi*0.025*t)*gaussian(t, 200, 60))
    
    # pylab.plot(string1.efield)
    pylab.plot(string2.efield)
    pylab.ylim(-1,1)
    pylab.savefig("/tmp/gaussian-%.3d.png"%t)