Example #1
0
sys.path.append('./solver-generic/')
sys.path.append('./writer-matlab/')

import pymbsolvelib as mb
import pysolvergeneric
import pywritermatlab

import numpy as np

dev = mb.device("test")

sce = mb.scenario("basic", 32768, 200e-15)

sce.add_record(mb.record("d11"))

sol = mb.solver("generic", dev, sce)

print('Solver ' + sol.get_name() + ' started')

sol.run()

print('Solver ' + sol.get_name() + ' finished')

wri = mb.writer("matlab")

outfile = dev.get_name() + "_" + sce.get_name() + "." + wri.get_extension()

results = sol.get_results()

print("I have " + str(len(results)) + " result(s)")
Example #2
0
# Ziolkowski setup
dev = mb.device("Song")
dev.add_region(mb.region("Active region", mat_ar, 0, 150e-6))

# scenario
sce = mb.scenario("Basic", 32768, 80e-15, rho_init)
sce.add_record(mb.record("e", 0.0, 0.0))
sce.add_record(mb.record("d11", mb.record.density, 1, 1, 0.0, 0.0))
sce.add_record(mb.record("d22", mb.record.density, 2, 2, 0.0, 0.0))
sce.add_record(mb.record("d33", mb.record.density, 3, 3, 0.0, 0.0))

# add source
sce.add_source(
    mb.sech_pulse("sech", 0.0, mb.source.hard_source, 3.5471e9, 3.8118e14,
                  17.248, 1.76 / 5e-15, -math.pi / 2))

# run solver
sol = mb.solver("openmp-3lvl-os-red", dev, sce)
print('Solver ' + sol.get_name() + ' started')
tic = time.time()
sol.run()
toc = time.time()
print('Solver ' + sol.get_name() + ' finished in ' + str(toc - tic) + ' sec')

# write results
wri = mb.writer("hdf5")
outfile = dev.get_name() + "_" + sce.get_name() + "." + wri.get_extension()
results = sol.get_results()
wri.write(outfile, sol.get_results(), dev, sce)
Example #3
0
dev = mb.device("Ziolkowski")
dev.add_region(mb.region("Vacuum left", mat_vac, 0, 7.5e-6))
dev.add_region(mb.region("Active region", mat_ar, 7.5e-6, 142.5e-6))
dev.add_region(mb.region("Vacuum right", mat_vac, 142.5e-6, 150e-6))

# initial density matrix
rho_init = mb.qm_operator([ 1, 0 ])

# scenario
sce = mb.scenario("Basic", 32768, 200e-15, rho_init)
sce.add_record(mb.record("inv12", 2.5e-15))
sce.add_record(mb.record("e", 2.5e-15))

# add source
sce.add_source(mb.sech_pulse("sech", 0.0, mb.source.hard_source, 4.2186e9,
                             2e14, 10, 2e14))

# run solver
sol = mb.solver("openmp-2lvl-os-red", dev, sce)
print('Solver ' + sol.get_name() + ' started')
tic = time.time()
sol.run()
toc = time.time()
print('Solver ' + sol.get_name() + ' finished in ' + str(toc - tic) + ' sec')

# write results
wri = mb.writer("hdf5")
outfile = dev.get_name() + "_" + sce.get_name() + "." + wri.get_extension()
results = sol.get_results()
wri.write(outfile, sol.get_results(), dev, sce)
Example #4
0
dev.add_region(mb.region("Vacuum left", mat_vac, 0, 7.5e-6))
dev.add_region(mb.region("Active region", mat_ar, 7.5e-6, 142.5e-6))
dev.add_region(mb.region("Vacuum right", mat_vac, 142.5e-6, 150e-6))

# scenario
sce = mb.scenario("Basic", 32768, 200e-15)
sce.add_record(mb.record("inv12", 2.5e-15))
sce.add_record(mb.record("e", 2.5e-15))
sce.set_dm_init_type(mb.scenario.lower_full)

# add source
sce.add_source(
    mb.sech_pulse("sech", 0.0, mb.source.hard_source, 4.2186e9 / 2, 2e14, 10,
                  2e14))

sol = mb.solver("openmp-2lvl-pc", dev, sce)

print('Solver ' + sol.get_name() + ' started')

tic = time.time()
sol.run()
toc = time.time()

print('Solver ' + sol.get_name() + ' finished in ' + str(toc - tic) + ' sec')

wri = mb.writer("matlab")

outfile = dev.get_name() + "_" + sce.get_name() + "." + wri.get_extension()

results = sol.get_results()
Example #5
0
# Ziolkowski setup
dev = mb.device("Song")
dev.add_region(mb.region("Active region", mat_ar, 0, 150e-6))

# scenario
sce = mb.scenario("Basic", 32768, 80e-15, rho_init)
sce.add_record(mb.record("e", 0.0, 0.0))
sce.add_record(mb.record("d11", mb.record.density, 1, 1, 0.0, 0.0))
sce.add_record(mb.record("d22", mb.record.density, 2, 2, 0.0, 0.0))
sce.add_record(mb.record("d33", mb.record.density, 3, 3, 0.0, 0.0))

# add source
sce.add_source(
    mb.sech_pulse("sech", 0.0, mb.source.hard_source, 3.5471e9, 3.8118e14,
                  17.248, 1.76 / 5e-15, -math.pi / 2))

# run solver
sol = mb.solver("cpu-fdtd-red-3lvl-cvr-rodr", dev, sce)
print('Solver ' + sol.get_name() + ' started')
tic = time.time()
sol.run()
toc = time.time()
print('Solver ' + sol.get_name() + ' finished in ' + str(toc - tic) + ' sec')

# write results
wri = mb.writer("hdf5")
outfile = dev.get_name() + "_" + sce.get_name() + "." + wri.get_extension()
results = sol.get_results()
wri.write(outfile, sol.get_results(), dev, sce)