예제 #1
0
def do_potentials(name_x, name_y, plates, plates_mf, dg0_arr, h_arr):

    print("Calculating %s-%s potentials, explicit tethers..." %
          (name_x, name_y))
    potentials = calc_potentials(plates, dg0_arr, h_arr)

    print("Calculating %s-%s potentials, mean field..." % (name_x, name_y))
    potentials_mf = calc_potentials(plates_mf, dg0_arr, h_arr)

    with open(
            os.path.join('results',
                         '%s_%s_plate_potentials.txt' % (name_x, name_y)),
            'w') as f:

        f.write('# DeltaG0 (kT)\t'
                'h (nm)\t'
                'Explicit pair potential (kT / nm^2)\t'
                'Mean field pair potential (kT / nm^2)\n')

        for dg0 in dg0_arr:
            for (h, V, Vmf) in zip(h_arr, potentials[dg0], potentials_mf[dg0]):
                f.write("%g\t%g\t%g\t%g\n" % (dg0, h / nm, V, Vmf))
            f.write("\n")

    try:
        with working_directory('gp'):
            subprocess.call([
                'gnuplot',
                'plot_%s_%s_plate_potentials.gp' % (name_x, name_y)
            ])
    except Exception:
        pass

    with open(
            os.path.join('results',
                         '%s_%s_sphere_potentials.txt' % (name_x, name_y)),
            'w') as f:

        f.write('# DeltaG0 (kT)\t'
                'h (nm)\t'
                'Explicit + Derjaguin Pair potential (kT)\t'
                'Mean field + Derjaguin Pair potential (kT)\n')

        for dg0 in dg0_arr:
            V_sphere = dnacc.calc_spheres_potential(h_arr, potentials[dg0], R)
            V_sphere_mf = dnacc.calc_spheres_potential(h_arr,
                                                       potentials_mf[dg0], R)

            for (h, V, Vmf) in zip(h_arr, V_sphere, V_sphere_mf):
                f.write("%g\t%g\t%g\t%g\n" % (dg0, h / nm, V, Vmf))
            f.write("\n")

    try:
        with working_directory('gp'):
            subprocess.call([
                'gnuplot',
                'plot_%s_%s_sphere_potentials.gp' % (name_x, name_y)
            ])
    except Exception:
        pass
예제 #2
0
def do_potentials(name_x, name_y, plates, plates_mf, dg0_arr, h_arr):

    print("Calculating %s-%s potentials, explicit tethers..." %
          (name_x, name_y))
    potentials = calc_potentials(plates, dg0_arr, h_arr)

    print("Calculating %s-%s potentials, mean field..." %
          (name_x, name_y))
    potentials_mf = calc_potentials(plates_mf, dg0_arr, h_arr)

    with open(os.path.join(
            'results',
            '%s_%s_plate_potentials.txt' % (name_x, name_y)), 'w') as f:

        f.write('# DeltaG0 (kT)\t' 'h (nm)\t'
                'Explicit pair potential (kT / nm^2)\t'
                'Mean field pair potential (kT / nm^2)\n')

        for dg0 in dg0_arr:
            for (h, V, Vmf) in zip(h_arr, potentials[dg0],
                                   potentials_mf[dg0]):
                f.write("%g\t%g\t%g\t%g\n" % (dg0, h / nm, V, Vmf))
            f.write("\n")

    try:
        with working_directory('gp'):
            subprocess.call(['gnuplot', 'plot_%s_%s_plate_potentials.gp' %
                             (name_x, name_y)])
    except Exception:
        pass

    with open(os.path.join(
            'results',
            '%s_%s_sphere_potentials.txt' % (name_x, name_y)), 'w') as f:

        f.write('# DeltaG0 (kT)\t' 'h (nm)\t'
                'Explicit + Derjaguin Pair potential (kT)\t'
                'Mean field + Derjaguin Pair potential (kT)\n')

        for dg0 in dg0_arr:
            V_sphere = dnacc.calc_spheres_potential(
                h_arr, potentials[dg0], R)
            V_sphere_mf = dnacc.calc_spheres_potential(
                h_arr, potentials_mf[dg0], R)

            for (h, V, Vmf) in zip(h_arr, V_sphere, V_sphere_mf):
                f.write("%g\t%g\t%g\t%g\n" % (dg0, h / nm, V, Vmf))
            f.write("\n")

    try:
        with working_directory('gp'):
            subprocess.call(['gnuplot', 'plot_%s_%s_sphere_potentials.gp' %
                             (name_x, name_y)])
    except Exception:
        pass
def do_it(beta_DeltaG0Mid):

    print 'Working on beta_DeltaG0Mid = %g' % beta_DeltaG0Mid

    # and various energy gaps
    for beta_Delta in xrange(0, 10):

        plates.beta_DeltaG0['alpha', 'beta1'] = \
            beta_DeltaG0Mid - 0.5 * beta_Delta
        plates.beta_DeltaG0['alpha', 'beta2'] = \
            beta_DeltaG0Mid + 0.5 * beta_Delta

        # and various total strand coverage
        for S in 0.75, 0.25:

            sigma = 1 / (S * L) ** 2
            ts[ALPHA]['sigma'] = sigma * 0.5

            with open('walk-S%0.2f-G0Mid%.1f-delta%.1f.dat' %
                      (S, beta_DeltaG0Mid, beta_Delta), 'w') as f:

                f.write('c\t' 'F_rep (kT)\n')
                offset = 0
                for c in np.linspace(1.0, 0.0, 21):

                    ts[BETA_1]['sigma'] = c * sigma
                    ts[BETA_2]['sigma'] = (1 - c) * sigma

                    # Calculate effective plate-plate potential
                    hArr = np.linspace(0.05 * L, 2.00 * L, 40)
                    VArr = [plates.at(h).free_energy_density
                            for h in hArr]

                    # and the resulting plate-sphere potential
                    Rplt = 1000.0 * R
                    betaF = dnacc.calc_spheres_potential(
                        hArr, VArr, R, Rplt)

                    # Find its minimum
                    minH, minBetaF = min(zip(hArr, betaF),
                                         key=operator.itemgetter(1))

                    if offset == 0:
                        offset = -minBetaF

                    f.write('%.2f\t%.4f\t%.4f\n' %
                            (c, minBetaF + offset, minH / nm))
예제 #4
0
def do_it(beta_DeltaG0Mid):

    print 'Working on beta_DeltaG0Mid = %g' % beta_DeltaG0Mid

    # and various energy gaps
    for beta_Delta in xrange(0, 10):

        plates.beta_DeltaG0['alpha', 'beta1'] = \
            beta_DeltaG0Mid - 0.5 * beta_Delta
        plates.beta_DeltaG0['alpha', 'beta2'] = \
            beta_DeltaG0Mid + 0.5 * beta_Delta

        # and various total strand coverage
        for S in 0.75, 0.25:

            sigma = 1 / (S * L)**2
            ts[ALPHA]['sigma'] = sigma * 0.5

            with open(
                    'walk-S%0.2f-G0Mid%.1f-delta%.1f.dat' %
                (S, beta_DeltaG0Mid, beta_Delta), 'w') as f:

                f.write('c\t' 'F_rep (kT)\n')
                offset = 0
                for c in np.linspace(1.0, 0.0, 21):

                    ts[BETA_1]['sigma'] = c * sigma
                    ts[BETA_2]['sigma'] = (1 - c) * sigma

                    # Calculate effective plate-plate potential
                    hArr = np.linspace(0.05 * L, 2.00 * L, 40)
                    VArr = [plates.at(h).free_energy_density for h in hArr]

                    # and the resulting plate-sphere potential
                    Rplt = 1000.0 * R
                    betaF = dnacc.calc_spheres_potential(hArr, VArr, R, Rplt)

                    # Find its minimum
                    minH, minBetaF = min(zip(hArr, betaF),
                                         key=operator.itemgetter(1))

                    if offset == 0:
                        offset = -minBetaF

                    f.write('%.2f\t%.4f\t%.4f\n' %
                            (c, minBetaF + offset, minH / nm))
예제 #5
0
        # Make plate potential first
        with open('plates-S%0.2f-G%.1f.dat' % (S, betaDeltaG0), 'w') as f:

            f.write('\t'.join([
                'h / L', "F_rep (kT/L^2)", "F_att (kT/L^2)", "F_plate (kT/L^2)"
            ]) + '\n')

            for h, V in zip(hArr, betaFPlate):
                betaFRep = plates.at(h).rep_free_energy_density
                betaFAtt = V - betaFRep

                f.write('%.7g\t%.7g\t%.7g\t%.7g\n' %
                        (h / L, betaFRep / (1 / L**2), betaFAtt / (1 / L**2),
                         (betaFRep + betaFAtt) / (1 / L**2)))

        # Now sphere potentials
        # (don't decompose into attractive and repulsive contributions,
        # although it's not hard to do)
        for R in 6.7, 25.0:
            betaFSphere = dnacc.calc_spheres_potential(hArr, betaFPlate, R * L)
            with open('spheres-R%.1f-S%0.2f-G%.1f.dat' % (R, S, betaDeltaG0),
                      'w') as f:

                f.write('\t'.join([
                    'h / L', "[ignore: F_rep (kT)]", "[ignore: F_att (kT)]",
                    "F_sphere (kT)"
                ]) + '\n')
                for h, V in zip(hArr, betaFSphere):
                    f.write('%.7g\t%.7g\t%.7g\t%.7g\n' % (h / L, 0, 0, V))
예제 #6
0
            )

    # Now compute a similar plate potential using the Poisson approximation
    badBetaFPlate = [-plates.at(h).sigma_bound[ALPHA, ALPHA_P] + plates.rep_free_energy_density for h in hArr]

    with open("bad-plates-A_B-T%.1f-G%.1f.txt" % (T, beta_DeltaG0), "w") as f:
        f.write("# h (nm)\t" "F_rep (kT/nm^2)\t" "F_att (kT/nm^2)\t" "F_plate (kT/nm^2)\n")

        for h, betaF, betaFRep in zip(hArr, badBetaFPlate, betaFRepPlate):
            betaFAtt = betaF - betaFRep
            f.write(
                "%g\t%g\t%g\t%g\n" % (h / nm, betaFRep / (1 / nm ** 2), betaFAtt / (1 / nm ** 2), betaF / (1 / nm ** 2))
            )

    # Now for sphere-sphere potentials
    betaFSpheres = dnacc.calc_spheres_potential(hArr, betaFPlate, R)
    betaFRepSpheres = dnacc.calc_spheres_potential(hArr, betaFRepPlate, R)

    with open("spheres-A_B-T%.1f-G%.1f.txt" % (T, beta_DeltaG0), "w") as f:
        f.write("# h (nm)\t" "F_rep (kT)\t" "F_att (kT)\t" "F_spheres (kT)\n")
        for h, betaF, betaFRep in zip(hArr, betaFSpheres, betaFRepSpheres):
            betaFAtt = betaF - betaFRep
            f.write("%g\t%g\t%g\t%g\n" % (h / nm, betaFRep, betaFAtt, betaF))

    # Same, but with the Poisson approximation
    badBetaFSpheres = dnacc.calc_spheres_potential(hArr, badBetaFPlate, R)

    with open("bad-spheres-A_B-T%.1f-G%.1f.txt" % (T, beta_DeltaG0), "w") as f:
        f.write("# h (nm)\t" "F_rep (kT)\t" "F_att (kT)\t" "F_spheres (kT)\n")
        for h, betaF, betaFRep in zip(hArr, badBetaFSpheres, betaFRepSpheres):
            betaFAtt = betaF - betaFRep
예제 #7
0
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

import dnacc
from dnacc.units import nm
import numpy as np

plates = dnacc.PlatesMeanField()

plates.add_tether_type(plate='lower',
                       sticky_end='alpha',
                       L=20 * nm,
                       sigma=1 / (20 * nm) ** 2)

plates.add_tether_type(plate='upper',
                       sticky_end='alphap',
                       L=20 * nm,
                       sigma=1 / (20 * nm) ** 2)

plates.beta_DeltaG0['alpha', 'alphap'] = -8  # in kT

plates.at(41 * nm).set_reference_now()

h_arr = np.linspace(1 * nm, 40 * nm, 40)
V_plate_arr = [plates.at(h).free_energy_density for h in h_arr]
R = 500 * nm
V_sphere_arr = dnacc.calc_spheres_potential(h_arr, V_plate_arr, R)

print("# h (nm)     V (kT)")
for (h, V) in zip(h_arr, V_sphere_arr):
    print (h / nm), V
예제 #8
0
    def test_potential_1(self):
        if (self.__dnacc):
            try:
                import dnacc
                from dnacc.units import nm
            except:
                pass
            else:
                self.__params = {
                    "r1": 500,
                    "r2": 500,
                    "lengths": {
                        "A": 20,
                        "B": 20
                    },
                    "sigma1": {
                        "A": 1 / 20.**2
                    },
                    "sigma2": {
                        "B": 1 / 20.**2
                    },
                    "beta_DeltaG0": {
                        ("A", "A"): 0,
                        ("A", "B"): -8,
                        ("B", "B"): 0
                    }
                }
                res = potential.DNACC(**self.__params)
                r = numpy.linspace(41 / 1000., 41, 1000) + 500. + 500.
                u, f = res.evaluate_array(r)

                # Example from documentation
                plates = dnacc.PlatesMeanField()
                plates.add_tether_type(plate='lower',
                                       sticky_end='alpha',
                                       L=20 * nm,
                                       sigma=1 / (20 * nm)**2)
                plates.add_tether_type(plate='upper',
                                       sticky_end='alphap',
                                       L=20 * nm,
                                       sigma=1 / (20 * nm)**2)
                plates.beta_DeltaG0['alpha', 'alphap'] = -8
                plates.at(41 * nm).set_reference_now()
                V_plate_arr = [
                    plates.at(rv - 1000.).free_energy_density for rv in r
                ]
                R = 500 * nm
                V_sphere_arr = dnacc.calc_spheres_potential(
                    r - 1000., V_plate_arr, R)

                # Compare results over the domain of the theory
                self.assertTrue(numpy.allclose(V_sphere_arr, u))

                # Check that potential is zero beyond cutoff
                self.assertEqual(res.evaluate(r[-1] + 0.00001), (0.0, 0.0))

                # Check that WCA-esque potential wall is used at contact and below
                rep_wallu, rep_wallf = res.evaluate_array(
                    numpy.linspace(0, r[0], 1000))

                # Wall is monotonically decreasing
                self.assertEqual(res.evaluate(0), (numpy.inf, numpy.inf))
                self.assertTrue(
                    numpy.all(rep_wallu[1:] < numpy.inf)
                    and numpy.all(rep_wallu[1:] > 0))
                self.assertTrue(
                    numpy.all(x > y for x, y in zip(rep_wallu, rep_wallu[1:])))
                self.assertTrue(
                    numpy.all(rep_wallf[1:] < numpy.inf)
                    and numpy.all(rep_wallf[1:] > 0))
                self.assertTrue(
                    numpy.all(x > y for x, y in zip(rep_wallf, rep_wallf[1:])))

                # Wall connects continuously
                self.assertTrue(numpy.isclose(rep_wallu[-1], u[0]))
                self.assertTrue(numpy.isclose(rep_wallf[-1], f[0]))
            f.write('\t'.join(['h / L',
                               "F_rep (kT/L^2)",
                               "F_att (kT/L^2)",
                               "F_plate (kT/L^2)"]) + '\n')

            for h, V in zip(hArr, betaFPlate):
                betaFRep = plates.at(h).rep_free_energy_density
                betaFAtt = V - betaFRep

                f.write('%.7g\t%.7g\t%.7g\t%.7g\n'
                        % (h / L, betaFRep / (1 / L ** 2),
                           betaFAtt / (1 / L ** 2),
                           (betaFRep + betaFAtt) / (1 / L ** 2)))

        # Now sphere potentials
        # (don't decompose into attractive and repulsive contributions,
        # although it's not hard to do)
        for R in 6.7, 25.0:
            betaFSphere = dnacc.calc_spheres_potential(
                hArr, betaFPlate, R * L)
            with open('spheres-R%.1f-S%0.2f-G%.1f.dat'
                      % (R, S, betaDeltaG0), 'w') as f:

                f.write('\t'.join(['h / L',
                                   "[ignore: F_rep (kT)]",
                                   "[ignore: F_att (kT)]",
                                   "F_sphere (kT)"]) + '\n')
                for h, V in zip(hArr, betaFSphere):
                    f.write('%.7g\t%.7g\t%.7g\t%.7g\n'
                            % (h / L, 0, 0, V))
예제 #10
0
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

import dnacc
from dnacc.units import nm
import numpy as np

plates = dnacc.PlatesMeanField()

plates.add_tether_type(plate='lower',
                       sticky_end='alpha',
                       L=20 * nm,
                       sigma=1 / (20 * nm)**2)

plates.add_tether_type(plate='upper',
                       sticky_end='alphap',
                       L=20 * nm,
                       sigma=1 / (20 * nm)**2)

plates.beta_DeltaG0['alpha', 'alphap'] = -8  # in kT

plates.at(41 * nm).set_reference_now()

h_arr = np.linspace(1 * nm, 40 * nm, 40)
V_plate_arr = [plates.at(h).free_energy_density for h in h_arr]
R = 500 * nm
V_sphere_arr = dnacc.calc_spheres_potential(h_arr, V_plate_arr, R)

print("# h (nm)     V (kT)")
for (h, V) in zip(h_arr, V_sphere_arr):
    print(h / nm), V