예제 #1
0
def run(soft):
    """
    Run this test

    soft: Path to SOFT executable
    """
    global TOLERANCE

    # Run with MPI
    print('Running SOFT with MPI...')
    broadutil.runSOFT_mpi("<pi>\nnum_threads=1;")

    # Load output
    vol = broadutil.SoVVolume("sovvolume.mat")
    volval_mpi = np.sum(vol.volumearray)

    # Run without MPI
    print('Running SOFT without MPI...')
    broadutil.runSOFT("<pi>")

    # Load all output
    vol = broadutil.SoVVolume("sovvolume.mat")
    volval = np.sum(vol.volumearray)

    dvol = np.abs((volval - volval_mpi) / volval)

    success = True
    if dvol > TOLERANCE:
        print(
            'ERROR: SoV volume was not computed properly when using MPI. Delta = {0:.5e}'
            .format(dvol))
        success = False

    return success
예제 #2
0
def run(soft):
    """
    Run this test

    soft: Path to SOFT executable
    """
    global _a, _rho, _p, _xi, DISTRIBUTION

    if not os.path.isfile(DISTRIBUTION):
        generateDistribution()

    broadutil.runSOFT("<pi>")
    img = broadutil.Image("image.mat")
    nval = np.sum(img.image)

    broadutil.runSOFT("<pi>\ndistribution_function = dist;")
    img = broadutil.Image("image.mat")
    ival = np.sum(img.image)

    f = distributionFunction(_a, _rho, _p, _xi)[0]
    d = np.abs(ival / nval - f)
    if d > 2 * np.finfo(float).eps:
        print(
            'ERROR: Distribution function was not applied properly. Delta = ' +
            str(d))
        return False

    return True
예제 #3
0
def run(soft):
    """
    Run this test

    soft: Path to SOFT executable
    """
    broadutil.runSOFT("<pi>")
    img = broadutil.Image("image.mat")
    nvalI = np.sum(img.image)

    gf = broadutil.Green("green.mat")
    dr = gf.r[0,1] - gf.r[0,0]
    nvalG = np.sum(gf.func) * dr

    print(dr)

    print(nvalI)
    print(nvalG)

    d = np.abs((nvalI - nvalG) / nvalI)
    if d > 2*np.finfo(float).eps:
        print('ERROR: Radial profile was not applied properly to unit distribution function. Delta = '+str(d))
        return False

    return True
예제 #4
0
파일: runtest.py 프로젝트: hoppe93/SOFT2
def run(soft):
    """
    Run this test

    soft: Path to SOFT executable
    """
    global TOLERANCE

    # Run with MPI
    print('Running SOFT with MPI...')
    broadutil.runSOFT_mpi("<pi>\nnum_threads=1;")

    # Load output
    gf = broadutil.Green("green.mat")
    gfval_mpi = np.sum(gf.func)

    # Run without MPI
    print('Running SOFT without MPI...')
    broadutil.runSOFT("<pi>")

    # Load all output
    gf = broadutil.Green("green.mat")
    gfval = np.sum(gf.func)

    dgf = np.abs((gfval - gfval_mpi)/gfval)

    success = True
    if dgf > TOLERANCE:
        print("ERROR: Green's function was not computed properly when using MPI. Delta = {0:.5e}".format(dgf))
        success = False

    return success
예제 #5
0
def runGreen():
    global PMIN, PMAX, NP, TMIN, TMAX, NT
    broadutil.runSOFT("<pi>\n@Radiation rad { output = green; }\n@ParticleGenerator PGen { p = "+str(PMIN)+","+str(PMAX)+","+str(NP)+"; thetap = "+str(TMIN)+","+str(TMAX)+","+str(NT)+"; }")

    # Load Green's function
    green = broadutil.Green("green.mat")
    P, THETAP = np.meshgrid(green.param1, green.param2)
    diffel = P**2 * np.sin(THETAP)
    return green, diffel
예제 #6
0
파일: runtest.py 프로젝트: hoppe93/SOFT2
def run(soft):
    """
    Run this test

    soft: Path to SOFT executable
    """
    global IMAGE_TOLERANCE, SPECTRUM_TOLERANCE, TOPVIEW_TOLERANCE

    # Run with MPI
    print('Running SOFT with MPI...')
    broadutil.runSOFT_mpi("<pi>\nnum_threads=1;")

    # Load all output
    img = broadutil.Image("image.mat")
    imgval_mpi = np.sum(img.image)

    spc = broadutil.Spectrum("spectrum.mat")
    spcval_mpi = np.sum(spc.I)

    tov = broadutil.Image("topview.mat")
    tovval_mpi = np.sum(tov.image)

    # Run without MPI
    print('Running SOFT without MPI...')
    broadutil.runSOFT("<pi>")

    # Load all output
    img = broadutil.Image("image.mat")
    imgval = np.sum(img.image)

    spc = broadutil.Spectrum("spectrum.mat")
    spcval = np.sum(spc.I)

    tov = broadutil.Image("topview.mat")
    tovval = np.sum(tov.image)

    dimg = np.abs((imgval - imgval_mpi) / imgval)
    dspc = np.abs((spcval - spcval_mpi) / spcval)
    dtov = np.abs((tovval - tovval_mpi) / tovval)

    success = True
    if dimg > IMAGE_TOLERANCE:
        print('ERROR: Image was not computed properly when using MPI.')
        success = False
    if dspc > SPECTRUM_TOLERANCE:
        print('ERROR: Spectrum was not computed properly when using MPI.')
        success = False
    if dtov > TOPVIEW_TOLERANCE:
        print('ERROR: Topview was not computed properly when using MPI.')
        success = False

    return success
예제 #7
0
def run(soft):
    """
    Run this test

    soft: Path to SOFT executable
    """
    global TOLERANCE

    # Run SOFT
    print('Running SOFT...')
    broadutil.runSOFT("<pi>")

    # Load all output
    img = broadutil.Image("isotropic.mat")
    imgval = img.image[0, 0]
    p = img.param1[0, 0]
    sinThetap = np.sin(img.param2[0, 0])

    # Compute received radiation using Python
    print('Computing integral...')

    t = time.time()
    recrad = ComputeReceivedRadiation(img)
    duration = time.time() - t

    # Add momentum jacobian (2pi from gyro integral)
    recrad *= p**2 * sinThetap / (2.0 * np.pi)

    print('Took {0}s'.format(duration))

    # Copmute relative error
    diso = np.abs((imgval - recrad) / imgval)

    success = True
    if diso > TOLERANCE:
        print('imgval = {0}'.format(imgval))
        print('recrad = {0}'.format(recrad))
        print(
            'ERROR: SOFT does not integrate isotropic radiation properly. Delta = {0}'
            .format(diso))
        success = False

    return success
예제 #8
0
def run(soft):
    """
    Run this test

    soft: Path to SOFT executable
    """
    global TOLERANCE, NPROCESSES

    # Run with MPI
    print('Running SOFT with MPI...')
    broadutil.runSOFT_mpi("<pi>\nnum_threads=1;", NPROCESSES)

    # Load output
    gfval_mpi = 0.0
    for i in range(0, NPROCESSES):
        gf = broadutil.Green("green{0}.mat".format(i))
        gfval_mpi += np.sum(gf.func)

    # Run without MPI
    print('Running SOFT without MPI...')
    broadutil.runSOFT(
        "<pi>\n@RadiationOutput green { mpi_mode = contiguous; }")

    # Load all output
    gf = broadutil.Green("green.mat")
    gfval = np.sum(gf.func)

    dgf = np.abs((gfval - gfval_mpi) / gfval)

    success = True
    if dgf > TOLERANCE:
        print(
            "ERROR: Green's function was not computed properly when using MPI. Delta = {0:.5e}"
            .format(dgf))
        success = False

    return success
예제 #9
0
def runSpectrum(p, thetap):
    broadutil.runSOFT("<pi>\n@Radiation rad { output = spectrum; }\n@ParticleGenerator PGen { p = "+str(p)+","+str(p)+",1; thetap = "+str(thetap)+","+str(thetap)+",1; }")

    # Load spectrum
    return broadutil.Spectrum("spectrum.mat")