Example #1
0
def main():
    print('{:-^60}'.format('Running two_molecules test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # twosphere
    print('Runs for two molecules')
    param = 'sphere_fine.param'
    test_name = 'twosphere'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param, delete_output=False)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # molecule_single_center
    print('Runs for isolated molecule')
    param = 'sphere_fine.param'
    test_name = 'molecule_single_center'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param, delete_output=False)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # load results for analysis
    Esolv, Esurf, Ecoul = test_outputs['twosphere'][2:5]
    Esolv_single, Esurf_single, Ecoul_single = test_outputs[
        'molecule_single_center'][2:5]
    Time = test_outputs['twosphere'][-1]
    Time_single = test_outputs['molecule_single_center'][-1]
    N, iterations = test_outputs['twosphere'][:2]

    total_time = Time
    Esolv_single *= 2  # Same molecule twice

    Einter = Esolv + Esurf + Ecoul - Esurf_single - Ecoul_single - Esolv_single
    total_time = Time + Time_single

    analytical, EE1, EE2 = an_solution.two_sphere(5., 12., 0.125, 4., 80., 1.)
    analytical *= 2

    error = abs(Einter - analytical) / abs(analytical)

    report_results(error,
                   N,
                   iterations,
                   Einter,
                   analytical,
                   total_time,
                   test_name='two molecules')
Example #2
0
def main():
    print('{:-^60}'.format('Running two_molecules test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # twosphere
    print('Runs for two molecules')
    param = 'sphere_fine.param'
    test_name = 'twosphere'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name,
            problem_folder,
            param, delete_output=False)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # molecule_single_center
    print('Runs for isolated molecule')
    param = 'sphere_fine.param'
    test_name = 'molecule_single_center'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name,
            problem_folder,
            param, delete_output=False)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # load results for analysis
    Esolv, Esurf, Ecoul = test_outputs['twosphere'][2:5]
    Esolv_single, Esurf_single, Ecoul_single = test_outputs[
        'molecule_single_center'][2:5]
    Time = test_outputs['twosphere'][-1]
    Time_single = test_outputs['molecule_single_center'][-1]
    N, iterations = test_outputs['twosphere'][:2]

    total_time = Time
    Esolv_single *= 2  # Same molecule twice

    Einter = Esolv + Esurf + Ecoul - Esurf_single - Ecoul_single - Esolv_single
    total_time = Time + Time_single

    analytical, EE1, EE2 = an_solution.two_sphere(5., 12., 0.125, 4., 80., 1.)
    analytical *= 2

    error = abs(Einter - analytical) / abs(analytical)

    report_results(error, N, iterations, Einter,
                   analytical, total_time, test_name='two molecules')
Example #3
0
def main():

    print('{:-^60}'.format('Running twosphere_neumann test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # twosphere_neumann
    print('Runs for two spherical surfaces with set dphidn')
    param = 'sphere_fine.param'
    test_name = 'twosphere_neumann'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # neumann_surface
    print('Runs for isolated surface')
    param = 'sphere_fine.param'
    test_name = 'neumann_surface'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    Esolv, Esurf, Ecoul = test_outputs['twosphere_neumann'][2:5]
    Esolv_surf, Esurf_surf, Ecoul_surf = test_outputs['neumann_surface'][2:5]
    Time = test_outputs['twosphere_neumann'][-1]
    Time_surf = test_outputs['neumann_surface'][-1]
    N, iterations = test_outputs['twosphere_neumann'][:2]

    Einter = Esurf - 2 * Esurf_surf  # Isolated sphere has to be done twice
    total_time = Time + Time_surf

    analytical = an_solution.constant_charge_twosphere_dissimilar(
        80 * 1., 80 * 1., 4., 4., 12., 0.125, 80.)

    error = abs(Einter - analytical) / abs(analytical)

    report_results(error,
                   N,
                   iterations,
                   Einter,
                   analytical,
                   total_time,
                   test_name='twosphere neumann')
Example #4
0
def main():

    print('{:-^60}'.format('Running twosphere_neumann test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # twosphere_neumann
    print('Runs for two spherical surfaces with set dphidn')
    param = 'sphere_fine.param'
    test_name = 'twosphere_neumann'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # neumann_surface
    print('Runs for isolated surface')
    param = 'sphere_fine.param'
    test_name = 'neumann_surface'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    Esolv, Esurf, Ecoul = test_outputs['twosphere_neumann'][2:5]
    Esolv_surf, Esurf_surf, Ecoul_surf = test_outputs['neumann_surface'][2:5]
    Time = test_outputs['twosphere_neumann'][-1]
    Time_surf = test_outputs['neumann_surface'][-1]
    N, iterations = test_outputs['twosphere_neumann'][:2]

    Einter = Esurf - 2 * Esurf_surf  # Isolated sphere has to be done twice
    total_time = Time + Time_surf

    analytical = an_solution.constant_charge_twosphere_dissimilar(
        80 * 1., 80 * 1., 4., 4., 12., 0.125, 80.)

    error = abs(Einter - analytical) / abs(analytical)

    report_results(error, N, iterations, Einter, analytical, total_time,
                   test_name='twosphere neumann')
Example #5
0
def main():
    print('{:-^60}'.format('Running sphere_molecule_single test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # molecule_single
    param = 'sphere_fine.param'
    test_name = 'molecule_single'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # load results for analysis
    Esolv, Esurf, Ecoul = test_outputs['molecule_single'][2:5]
    Time = test_outputs['molecule_single'][-1]
    N, iterations = test_outputs['molecule_single'][:2]

    total_time = Time

    analytical = an_solution.an_P(
        numpy.array([1.]), numpy.array([[1., 1., 1.41421356]]), 4., 80., 5.,
        0.125, 5., 20)

    error = abs(Esolv - analytical) / abs(analytical)

    report_results(error,
                   N,
                   iterations,
                   Esolv,
                   analytical,
                   total_time,
                   energy_type='Total',
                   test_name='sphere molecule single')
Example #6
0
def main():
    print('{:-^60}'.format('Running sphere_neumann test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # neumann_surface
    param = 'sphere_fine.param'
    test_name = 'neumann_surface'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # load results for analysis
    Esolv, Esurf, Ecoul = test_outputs['neumann_surface'][2:5]
    Time = test_outputs['neumann_surface'][-1]
    N, iterations = test_outputs['neumann_surface'][:2]

    Etotal = Esolv + Esurf + Ecoul
    total_time = Time

    analytical = an_solution.constant_charge_single_energy(-80 * 1, 4, 0.125,
                                                           80)

    error = abs(Etotal - analytical) / abs(analytical)

    report_results(error,
                   N,
                   iterations,
                   Etotal,
                   analytical,
                   total_time,
                   energy_type='Total',
                   test_name='sphere neumann')
Example #7
0
def main():

    print('{:-^60}'.format('Running molecule_dirichlet test'))

    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # molecule_dirichlet
    param = 'sphere_fine.param'
    test_name = 'molecule_dirichlet'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # molecule_single_center
    param = 'sphere_fine.param'
    test_name = 'molecule_single_center'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # dirichlet_surface
    param = 'sphere_fine.param'
    test_name = 'dirichlet_surface'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    Esolv, Esurf, Ecoul = test_outputs['molecule_dirichlet'][2:5]
    Esolv_mol, Esurf_mol, Ecoul_mol = test_outputs['molecule_single_center'][2:
                                                                             5]
    Esolv_surf, Esurf_surf, Ecoul_surf = test_outputs['dirichlet_surface'][2:5]
    Time = test_outputs['molecule_dirichlet'][-1]
    Time_mol = test_outputs['molecule_single_center'][-1]
    Time_surf = test_outputs['dirichlet_surface'][-1]
    N, iterations = test_outputs['molecule_dirichlet'][:2]

    Einter = (Esolv + Esurf + Ecoul - Esolv_surf - Esurf_mol - Ecoul_mol -
              Esolv_mol - Esurf_surf - Ecoul_surf)
    total_time = Time + Time_mol + Time_surf

    analytical = an_solution.molecule_constant_potential(1., 1., 5., 4., 12.,
                                                         0.125, 4., 80.)

    error = abs(Einter - analytical) / abs(analytical)

    report_results(error, N, iterations, Einter, analytical, total_time, test_name='molecule dirichlet')
Example #8
0
def main():
    print('{:-^60}'.format('Running sphere_neumann test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # neumann_surface
    param = 'sphere_fine.param'
    test_name = 'neumann_surface'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # load results for analysis
    Esolv, Esurf, Ecoul = test_outputs['neumann_surface'][2:5]
    Time = test_outputs['neumann_surface'][-1]
    N, iterations = test_outputs['neumann_surface'][:2]

    Etotal = Esolv + Esurf + Ecoul
    total_time = Time

    analytical = an_solution.constant_charge_single_energy(
        -80 * 1, 4, 0.125, 80)

    error = abs(Etotal - analytical) / abs(analytical)

    report_results(error,
                   N,
                   iterations,
                   Etotal,
                   analytical,
                   total_time,
                   energy_type='Total',
                   test_name='sphere neumann')
Example #9
0
def main():

    print('{:-^60}'.format('Running molecule_dirichlet test'))

    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # molecule_dirichlet
    param = 'sphere_fine.param'
    test_name = 'molecule_dirichlet'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # molecule_single_center
    param = 'sphere_fine.param'
    test_name = 'molecule_single_center'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # dirichlet_surface
    param = 'sphere_fine.param'
    test_name = 'dirichlet_surface'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    Esolv, Esurf, Ecoul = test_outputs['molecule_dirichlet'][2:5]
    Esolv_mol, Esurf_mol, Ecoul_mol = test_outputs['molecule_single_center'][
        2:5]
    Esolv_surf, Esurf_surf, Ecoul_surf = test_outputs['dirichlet_surface'][2:5]
    Time = test_outputs['molecule_dirichlet'][-1]
    Time_mol = test_outputs['molecule_single_center'][-1]
    Time_surf = test_outputs['dirichlet_surface'][-1]
    N, iterations = test_outputs['molecule_dirichlet'][:2]

    Einter = (Esolv + Esurf + Ecoul - Esolv_surf - Esurf_mol - Ecoul_mol -
              Esolv_mol - Esurf_surf - Ecoul_surf)
    total_time = Time + Time_mol + Time_surf

    analytical = an_solution.molecule_constant_potential(
        1., 1., 5., 4., 12., 0.125, 4., 80.)

    error = abs(Einter - analytical) / abs(analytical)

    report_results(error,
                   N,
                   iterations,
                   Einter,
                   analytical,
                   total_time,
                   test_name='molecule dirichlet')
Example #10
0
def main():
    print('{:-^60}'.format('Running molecule_neumann test'))

    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # molecule_neumann
    print('Runs for molecule + set phi/dphi surface')
    param = 'sphere_fine.param'
    test_name = 'molecule_neumann'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # molecule_single_center
    print('Runs for isolated molecule')
    param = 'sphere_fine.param'
    test_name = 'molecule_single_center'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # neumann_surface
    print('Runs for isolated surface')
    param = 'sphere_fine.param'
    test_name = 'neumann_surface'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # Load results for analysis
    Esolv, Esurf, Ecoul = test_outputs['molecule_neumann'][2:5]
    Esolv_mol, Esurf_mol, Ecoul_mol = test_outputs['molecule_single_center'][
        2:5]
    Esolv_surf, Esurf_surf, Ecoul_surf = test_outputs['neumann_surface'][2:5]
    Time = test_outputs['molecule_neumann'][-1]
    Time_mol = test_outputs['molecule_single_center'][-1]
    Time_surf = test_outputs['neumann_surface'][-1]
    N, iterations = test_outputs['molecule_neumann'][:2]

    Einter = (Esolv + Esurf + Ecoul - Esolv_surf - Esurf_mol - Ecoul_mol -
              Esolv_mol - Esurf_surf - Ecoul_surf)
    total_time = Time + Time_mol + Time_surf

    analytical = an_solution.molecule_constant_charge(1., -80 * 1., 5., 4.,
                                                      12., 0.125, 4., 80.)

    error = abs(Einter - analytical) / abs(analytical)

    report_results(error,
                   N,
                   iterations,
                   Einter,
                   analytical,
                   total_time,
                   test_name='molecule neumann')
Example #11
0
def main():
    print('{:-^60}'.format('Running molecule_neumann test'))

    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # molecule_neumann
    print('Runs for molecule + set phi/dphi surface')
    param = 'sphere_fine.param'
    test_name = 'molecule_neumann'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # molecule_single_center
    print('Runs for isolated molecule')
    param = 'sphere_fine.param'
    test_name = 'molecule_single_center'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # neumann_surface
    print('Runs for isolated surface')
    param = 'sphere_fine.param'
    test_name = 'neumann_surface'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # Load results for analysis
    Esolv, Esurf, Ecoul = test_outputs['molecule_neumann'][2:5]
    Esolv_mol, Esurf_mol, Ecoul_mol = test_outputs['molecule_single_center'][2:
                                                                             5]
    Esolv_surf, Esurf_surf, Ecoul_surf = test_outputs['neumann_surface'][2:5]
    Time = test_outputs['molecule_neumann'][-1]
    Time_mol = test_outputs['molecule_single_center'][-1]
    Time_surf = test_outputs['neumann_surface'][-1]
    N, iterations = test_outputs['molecule_neumann'][:2]

    Einter = (Esolv + Esurf + Ecoul - Esolv_surf - Esurf_mol - Ecoul_mol -
              Esolv_mol - Esurf_surf - Ecoul_surf)
    total_time = Time + Time_mol + Time_surf

    analytical = an_solution.molecule_constant_charge(1., -80 * 1., 5., 4.,
                                                      12., 0.125, 4., 80.)

    error = abs(Einter - analytical) / abs(analytical)

    report_results(error, N, iterations, Einter, analytical, total_time,
                   test_name='molecule neumann')
Example #12
0
def main():
    print('{:-^60}'.format('Running lysozyme test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # lys_single
    param = 'lys.param'
    test_name = 'lys_single'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # lys
    param = 'lys.param'
    test_name = 'lys'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # lys_k0
    print('Simulations for Lysozyme with kappa=0')
    param = 'lys.param'
    test_name = 'lys_k0'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(
            mesh, test_name, problem_folder, param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    Esolv_single, Esurf_single, Ecoul_single = test_outputs['lys_single'][2:5]
    Esolv_full, Esurf_full, Ecoul_full = test_outputs['lys'][2:5]
    Esolv_k0, Esurf_k0, Ecoul_k0 = test_outputs['lys_k0'][2:5]
    iterations_single = test_outputs['lys_single'][1]
    iterations_full = test_outputs['lys'][1]
    iterations_k0 = test_outputs['lys_k0'][1]

    Esolv_ref_single = 1 / 4.184 * numpy.array(
        [-2401.2, -2161.8, -2089, -2065.5])
    Esolv_ref_full = 1 / 4.184 * numpy.array(
        [-2432.9, -2195.9, -2124.2, -2101.1])
    Esolv_FFTSVD = numpy.array([-577.105, -520.53, -504.13, -498.26
                                ])  # Remember FFTSVD was only run with kappa=0

    iter_ref_single = numpy.array([33, 34, 35, 39])
    iter_ref_full = numpy.array([36, 38, 41, 45])
    iter_FFTSVD = numpy.array([32, 34, 35, 37])

    error_single = abs(Esolv_single - Esolv_ref_single) / abs(Esolv_ref_single)
    error_full = abs(Esolv_full - Esolv_ref_full) / abs(Esolv_ref_full)
    error_FFTSVD = abs(Esolv_k0 - Esolv_FFTSVD) / abs(Esolv_FFTSVD)

    iter_diff_single = iterations_single - iter_ref_single
    iter_diff_full = iterations_full - iter_ref_full
    iter_diff_FFTSVD = iterations_k0 - iter_FFTSVD

    flag = 0
    thresh = 1e-2
    with open('convergence_test_results', 'a') as f:
        print('-' * 60, file=f)
        print('{:-^60}'.format('Running lysozyme test'), file=f)
        print('-' * 60, file=f)
        print(datetime.datetime.now(), file=f)
        for i in range(len(error_single)):
            if error_single[i] > thresh:
                flag = 1
                print(
                    'Solvation energy not agreeing for single surface simulation,'
                    'mesh {} by {}'.format(i, error_single[i]),
                    file=f)

            if error_full[i] > thresh:
                flag = 1
                print(
                    'Solvation energy not agreeing for full surface simulation,'
                    'mesh {} by {}'.format(i, error_full[i]),
                    file=f)

            if error_FFTSVD[i] > thresh:
                flag = 1
                print('Solvation energy not agreeing with FFTSVD, mesh {} by'
                      '{}'.format(i, error_FFTSVD[i]),
                      file=f)

        if flag == 0:
            print('\nPassed Esolv test!', file=f)
        else:
            print('\nFAILED Esolv test', file=f)

        flag = 0
        thresh = 3
        for i in range(len(iter_diff_single)):
            if abs(iter_diff_single[i]) > thresh:
                flag = 1
                print(
                    'Solvation energy not agreeing for single surface simulation,'
                    'mesh {} by {}'.format(i, iter_diff_single[i]),
                    file=f)

            if abs(iter_diff_full[i]) > thresh:
                flag = 1
                print(
                    'Solvation energy not agreeing for full surface simulation, '
                    'mesh {} by {}'.format(i, iter_diff_full[i]),
                    file=f)

            if abs(iter_diff_FFTSVD[i]) > thresh:
                flag = 1
                print('Solvation energy not agreeing with FFTSVD,'
                      'mesh {} by {}'.format(i, iter_diff_FFTSVD[i]),
                      file=f)

        if flag == 0:
            print(
                '\nPassed iterations test! They are all within {} iterations of '
                'reference'.format(thresh),
                file=f)
        else:
            print('\nFAILED iterations test', file=f)

        print('Summary:', file=f)
        print('Single: Esolv: ',
              str(Esolv_single),
              ', iterations: ',
              str(iterations_single),
              file=f)
        print('Full  : Esolv: ',
              str(Esolv_full),
              ', iterations: ',
              str(iterations_full),
              file=f)
        print('k=0   : Esolv: ',
              str(Esolv_k0),
              ', iterations: ',
              str(iterations_k0),
              file=f)
Example #13
0
def main():
    print('{:-^60}'.format('Running lysozyme test'))
    try:
        test_outputs = pickleload()
    except FileNotFoundError:
        test_outputs = {}

    problem_folder = 'input_files'

    # lys_single
    param = 'lys.param'
    test_name = 'lys_single'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(mesh,
                                                                   test_name,
                                                                   problem_folder,
                                                                   param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # lys
    param = 'lys.param'
    test_name = 'lys'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(mesh,
                                                                   test_name,
                                                                   problem_folder,
                                                                   param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    # lys_k0
    print('Simulations for Lysozyme with kappa=0')
    param = 'lys.param'
    test_name = 'lys_k0'
    if test_name not in test_outputs.keys():
        N, iterations, Esolv, Esurf, Ecoul, Time = run_convergence(mesh,
                                                                   test_name,
                                                                   problem_folder,
                                                                   param)
        test_outputs[test_name] = [N, iterations, Esolv, Esurf, Ecoul, Time]

    picklesave(test_outputs)

    Esolv_single, Esurf_single, Ecoul_single = test_outputs['lys_single'][2:5]
    Esolv_full, Esurf_full, Ecoul_full = test_outputs['lys'][2:5]
    Esolv_k0, Esurf_k0, Ecoul_k0 = test_outputs['lys_k0'][2:5]
    iterations_single = test_outputs['lys_single'][1]
    iterations_full = test_outputs['lys'][1]
    iterations_k0 = test_outputs['lys_k0'][1]

    Esolv_ref_single = 1/4.184*numpy.array([-2401.2, -2161.8, -2089, -2065.5])
    Esolv_ref_full = 1/4.184*numpy.array([-2432.9, -2195.9, -2124.2, -2101.1])
    Esolv_FFTSVD = numpy.array([-577.105, -520.53, -504.13, -498.26])  # Remember FFTSVD was only run with kappa=0

    iter_ref_single = numpy.array([33, 34, 35, 39])
    iter_ref_full = numpy.array([36, 38, 41, 45])
    iter_FFTSVD = numpy.array([32, 34, 35, 37])

    error_single = abs(Esolv_single - Esolv_ref_single) / abs(Esolv_ref_single)
    error_full = abs(Esolv_full - Esolv_ref_full) / abs(Esolv_ref_full)
    error_FFTSVD = abs(Esolv_k0 - Esolv_FFTSVD) / abs(Esolv_FFTSVD)

    iter_diff_single = iterations_single - iter_ref_single
    iter_diff_full = iterations_full - iter_ref_full
    iter_diff_FFTSVD = iterations_k0 - iter_FFTSVD

    flag = 0
    thresh = 1e-2
    with open('convergence_test_results', 'a') as f:
        print('-' * 60, file=f)
        print('{:-^60}'.format('Running lysozyme test'), file=f)
        print('-' * 60, file=f)
        print(datetime.datetime.now(), file=f)
        for i in range(len(error_single)):
            if error_single[i] > thresh:
                flag = 1
                print('Solvation energy not agreeing for single surface simulation,'
                      'mesh {} by {}'.format(i, error_single[i]), file=f)

            if error_full[i] > thresh:
                flag = 1
                print('Solvation energy not agreeing for full surface simulation,'
                    'mesh {} by {}'.format(i, error_full[i]), file=f)

            if error_FFTSVD[i] > thresh:
                flag = 1
                print('Solvation energy not agreeing with FFTSVD, mesh {} by'
                    '{}'.format(i, error_FFTSVD[i]), file=f)

        if flag == 0:
            print('\nPassed Esolv test!', file=f)
        else:
            print('\nFAILED Esolv test', file=f)

        flag = 0
        thresh = 3
        for i in range(len(iter_diff_single)):
            if abs(iter_diff_single[i]) > thresh:
                flag = 1
                print('Solvation energy not agreeing for single surface simulation,'
                    'mesh {} by {}'.format(i, iter_diff_single[i]), file=f)

            if abs(iter_diff_full[i]) > thresh:
                flag = 1
                print('Solvation energy not agreeing for full surface simulation, '
                    'mesh {} by {}'.format(i, iter_diff_full[i]), file=f)

            if abs(iter_diff_FFTSVD[i]) > thresh:
                flag = 1
                print('Solvation energy not agreeing with FFTSVD,'
                    'mesh {} by {}'.format(i, iter_diff_FFTSVD[i]), file=f)

        if flag == 0:
            print('\nPassed iterations test! They are all within {} iterations of '
                'reference'.format(thresh), file=f)
        else:
            print('\nFAILED iterations test', file=f)

        print('Summary:', file=f)
        print('Single: Esolv: ', str(Esolv_single),', iterations: ',
              str(iterations_single), file=f)
        print('Full  : Esolv: ', str(Esolv_full), ', iterations: ',
              str(iterations_full), file=f)
        print('k=0   : Esolv: ', str(Esolv_k0), ', iterations: ',
              str(iterations_k0), file=f)