Exemplo n.º 1
0
def printUndSourceSizeSDV(ring, phEnergy, lengthUnd, beta=0):
    '''
    SAME THAN LIC: THESIS. beta = 0




    WG: 20150514, change of the return var structure
    '''

    [
        sdvRad, sdvDivRad, sdvXe, sdvDivXe, sdvYe, sdvDivYe, sdvXt, sdvDivXt,
        sdvYt, sdvDivYt, maxOpenAngleX, maxOpenAngleY
    ] = calculateUndSourcePropertiesSDV(ring, phEnergy, lengthUnd, beta)

    wgt.color_print(
        'WG: Calculation sdv Source Size and Divergences at %.2f ' %
        (phEnergy) + 'eV for beta = %.2f:' % (beta))

    wgt.color_print('WG: %s' % (ring.name))
    wgt.color_print('WG: Undulator Length %f' % (lengthUnd))

    print('WG: sdvRad: %.4g um' % (sdvRad * 1e6))
    print('WG: sdvDivRad: %.4g urad' % (sdvDivRad * 1e6))
    print('WG: sdvXt: %.4g um' % (sdvXt * 1e6))
    print('WG: sdvYt: %.4g um' % (sdvYt * 1e6))
    print('WG: sdvDivXt: %.4g urad' % (sdvDivXt * 1e6))
    print('WG: sdvDivYt: %.4g urad' % (sdvDivYt * 1e6))
    print('WG: max apert cent. cone X: ± %.4g urad' % (maxOpenAngleX * 1e6))
    print('WG: max apert cent. cone Y: ± %.4g urad' % (maxOpenAngleY * 1e6))

    print('WG: done!\n\n')
Exemplo n.º 2
0
def printUndSourceSizeGaussianApprox(ring, phEnergy, lengthUnd):
    # SAME THAN LIC: THESIS. beta = 0

    [[sigRad, sigDivRad], _, [sigXt, sigDivXt], [sigYt, sigDivYt]
     ] = calculateUndSourcePropertiesGaussian(ring, phEnergy, lengthUnd)

    wgt.color_print(
        'WG: Calculation Sig Source Size and Divergences at %.2f eV' %
        (phEnergy))
    wgt.color_print('WG: It uses gaussian approximation (not sinc function)')

    wgt.color_print('WG: %s' % (ring.name))
    wgt.color_print('WG: Undulator Length %f' % (lengthUnd))

    print('WG: sigRad: %.4g um' % (sigRad * 1e6))
    print('WG: sigDivRad: %.4g urad' % (sigDivRad * 1e6))
    print('WG: sigXt: %.4g um' % (sigXt * 1e6))
    print('WG: sigYt: %.4g um' % (sigYt * 1e6))
    print('WG: sigDivXt: %.4g urad' % (sigDivXt * 1e6))
    print('WG: sigDivYt: %.4g urad' % (sigDivYt * 1e6))

    print('WG: done!\n\n')
Exemplo n.º 3
0
#==============================================================================
# %% Some definitions
#==============================================================================

wavelength = 1.239842e-6 / 1e3
alpha = 00.0 * np.pi / 180
beta = -alpha
r = 10.00
rp = 5.0

ny1, nz1 = 61, 61
ny2, nz2 = 31, 31
nl, nw = 51, 51  # try to have same dw and dl

if rank == 0:
    wgt.color_print('WG: Total number of points: %.4g' %
                    (ny1 * nz1 * ny2 * nz2 * nl * nw))
    print('ny1, nz1: %d, %d' % (ny1, nz1))
    print('ny2, nz2: %d, %d' % (ny2, nz2))
    print('nl, nw: %d, %d' % (nl, nw))

#wgt.wait_keyboard()

#==============================================================================
# %% U1
#==============================================================================

Ly1, Lz1 = 1e-3, 1e-3

y1_vec = np.mgrid[-Ly1 / 2:Ly1 / 2:ny1 * 1j]
z1_vec = np.mgrid[-Lz1 / 2:Lz1 / 2:nz1 * 1j]
sys.path.append('/home/wcgrizolli/pythonWorkspace/wgTools')
import wgTools as wgt
from myOpticsLib import gaussianBeam

#==============================================================================
# %% Get input parameters
#==============================================================================

if len(sys.argv) == 7:

    ny1, nz1 = int(sys.argv[1]), int(sys.argv[2])
    ny2, nz2 = int(sys.argv[3]), int(sys.argv[4])
    nl, nw = int(sys.argv[5]), int(sys.argv[6])

else:
    wgt.color_print('##### ERROR: wrong number of parameters!')
    wgt.color_print(
        '''##### ERROR: use no parmaters or 6 parameters as foolowing:
    par1: ny1
    par2: nz1
    par3: ny2
    par4: nz2


    Suggestion:
      python fk_integral_toroid_mpi_scan.py 31 31 61 61 51 101
      mpiexec -n 3 python fk_integral_toroid_mpi_scan.py 31 31 61 61 51 101
      ''')
    wgt.printFilename()
    print('WG: Number of parameters:' + str(len(sys.argv)))
    print('WG: Input parameters:')
Exemplo n.º 5
0
[Mx, My] = [1001, 1001]
dx = Lx / Mx
dy = Ly / My

#zz = 1.00  # XXX: dist to propag
#Lx2 = Lx

zz = .00322808  # XXX: dist to propag
Lx2 = Lx / 2500.0

print('WG: sampling x=' + str(Mx))
print('WG: sampling y=' + str(My))

# %%
if Mx > 1001 or My > 1001:
    wgt.color_print('WG: Sampling bigger than 1001^2, stoping the program')
#    sys.exit()

##=========================================================#
# %% 2D u1 function
##=========================================================#


def circ(X, Y, wx, wy, Xo=0.0, Yo=0.0):  # circular
    out = X * 0.0
    out[abs(((X - Xo) / wx)**2 + ((Y - Yo) / wy)**2) < 0.5**2] = 1.0
    out[abs(((X - Xo) / wx)**2 + ((Y - Yo) / wy)**2) == 0.5**2] = .50
    return out


def tFuncLens(X, Y, wavelength, fx=1e23, fy=1e23):