# Path: dnacc/units.py
# _GSL_CONST_MKSA_UNIFIED_ATOMIC_MASS = 1.660538782e-27  # kg
# _GSL_CONST_MKSA_ELECTRON_CHARGE = 1.602176487e-19  # A s
# _GSL_CONST_NUM_AVOGADRO = 6.02214199e23  # 1 / mol
# _GSL_CONST_MKSA_GAUSS = 1e-4  # kg / A s^2
# _GSL_CONST_MKSA_BAR = 1e5  # kg / m s^2
# _GSL_CONST_MKSA_STD_ATMOSPHERE = 1.01325e5  # kg / m s^2
# _GSL_CONST_MKSA_TORR = 1.33322368421e2  # kg / m s^2
# _GSL_CONST_MKSA_METER_OF_MERCURY = 1.33322368421e5  # kg / m s^2
# K = 1.0
#     A = Ampere
# N = kg * m / s ** 2
# J = N * m
# W = J / s
# C = Ampere * s
# V = J / C
# F = C / V
# S = 1 / Ohm
# T = Wb / m ** 2
# H = Wb / Ampere
# L = dm ** 3
# G = _GSL_CONST_MKSA_GAUSS * T
# P = 1 * g / (cm * s)
# AA = 1e-10 * m
# M = mol / L
# def add_amperes_unit():
# def _add_prefixes(name, realname=None):


import numpy as np
import subprocess
import scipy.interpolate
import dnacc
from math import pi, sqrt
from dnacc.units import nm
def setup_explicit(sphere_list, patches):

    # Set up system
    spheres = dnacc.Spheres()
    spheres.set_tether_prototype(L=L)

    for name, props in sphere_list.iteritems():
        spheres.add_sphere(name, props['centre'], props['radius'])

    # Generate grafting points for patches centered at 0.0
    ids = list()
    for patch_props in patches:

        patch_ids = dnacc.patches.add_circular_patch_to_sphere(
            spheres, **patch_props)

        ids.extend(patch_ids)

    # Record original positions
    for i in ids:
        spheres.tethers[i]['orig_pos'] = np.array(spheres.tethers[i]['pos'])

    return spheres


# Main module
# ===========

np.random.seed(1)  # To make the following plots deterministic


# Path: dnacc/units.py
# _GSL_CONST_MKSA_UNIFIED_ATOMIC_MASS = 1.660538782e-27  # kg
# _GSL_CONST_MKSA_ELECTRON_CHARGE = 1.602176487e-19  # A s
# _GSL_CONST_NUM_AVOGADRO = 6.02214199e23  # 1 / mol
# _GSL_CONST_MKSA_GAUSS = 1e-4  # kg / A s^2
# _GSL_CONST_MKSA_BAR = 1e5  # kg / m s^2
# _GSL_CONST_MKSA_STD_ATMOSPHERE = 1.01325e5  # kg / m s^2
# _GSL_CONST_MKSA_TORR = 1.33322368421e2  # kg / m s^2
# _GSL_CONST_MKSA_METER_OF_MERCURY = 1.33322368421e5  # kg / m s^2
# K = 1.0
#     A = Ampere
# N = kg * m / s ** 2
# J = N * m
# W = J / s
# C = Ampere * s
# V = J / C
# F = C / V
# S = 1 / Ohm
# T = Wb / m ** 2
# H = Wb / Ampere
# L = dm ** 3
# G = _GSL_CONST_MKSA_GAUSS * T
# P = 1 * g / (cm * s)
# AA = 1e-10 * m
# M = mol / L
# def add_amperes_unit():
# def _add_prefixes(name, realname=None):


# Path: examples/explicit_patches_spheres/explicit_patches_spheres.py
import numpy as np
import subprocess
import scipy.interpolate
import dnacc
from math import pi, sqrt
from dnacc.units import nm

def setup_explicit(sphere_list, patches):

    # Set up system
    spheres = dnacc.Spheres()
    spheres.set_tether_prototype(L=L)

    for name, props in sphere_list.iteritems():
        spheres.add_sphere(name, props['centre'], props['radius'])

    # Generate grafting points for patches centered at 0.0
    ids = list()
    for patch_props in patches:

        patch_ids = dnacc.patches.add_circular_patch_to_sphere(
            spheres, **patch_props)

        ids.extend(patch_ids)

    # Record original positions
    for i in ids:
        spheres.tethers[i]['orig_pos'] = np.array(spheres.tethers[i]['pos'])

    return spheres


# Main module
# ===========

np.random.seed(1)  # To make the following plots deterministic


L = 20 * nm