123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- from scattnlay import fieldnlay
- from scattnlay import scattnlay
- import cmath
- import matplotlib.pyplot as plt
- import numpy as np
- import scattnlay
- import quadpy
- index_Ag = 4.0
- nm = 1.0
- WL_units='nm'
- x = np.ones((1), dtype = np.float64)
- m = np.ones((1), dtype = np.complex128)
- core_r = 120
- WL = 550
- x[0] = 2.0*np.pi*core_r/WL
- m[0] = index_Ag/nm
- R = x[0]*1.31
- comment='bulk-NP-WL'+str(WL)+WL_units
- quad_ord = 19
- coord = quadpy.sphere.Lebedev(3).points
- def force(in_coord):
- coord = in_coord.T
- terms, Eall, Hall = fieldnlay(np.array([x]), np.array([m]), coord)
- E_all = Eall[0, :, :]
- H_all = Hall[0, :, :]
-
-
-
-
-
-
-
-
- unit_all = coord/ R
- P = np.array([
- ( (1/(2.0))
- *np.real(
- np.dot(unit,E)*np.conj(E) +
- np.dot(unit,H)*np.conj(H) +
- (-1.0/2.0)*(np.dot(E,np.conj(E))
- +np.dot(H,np.conj(H))
- )*unit
- )
- )
- for unit,E,H in zip(unit_all,E_all, H_all)
- ])
- return P.T
- def poynting(in_coord):
- coord = in_coord.T
- terms, Eall, Hall = fieldnlay(np.array([x]), np.array([m]), coord)
- E_all = Eall[0, :, :]
- H_all = Hall[0, :, :]
- unit_all = coord/ R
- P = np.array([
- ( ( 1/(2.0) )
- *np.real(
- np.cross(E,np.conj(H))
- )
- )
- for unit,E,H in zip(unit_all,E_all, H_all)
- ])
- return P.T
- val = quadpy.sphere.integrate(
- poynting
- ,
- [0.0, 0.0, 0.0], R,
- quadpy.sphere.Lebedev(quad_ord)
- )
- print(val)
- print("Random increase of integraion sphere radius...")
- val = quadpy.sphere.integrate(
-
- poynting
- ,
- [0.0, 0.0, 0.0], R*2.718,
- quadpy.sphere.Lebedev(quad_ord)
- )
- print(val)
|