Example #1
0
 def ff(self, r1, r2, r3):
     exp = 10**-18
     res = (r2/2)*(r3**2-r1**2)*np.arcsinh(r2/(np.sqrt(r1**2+r3**2)+exp))+\
             (r3/2)*(r2**2-r1**2)*np.arcsinh(r3/(np.sqrt(r1**2+r2**2)+exp))-\
             r1*r2*r3*np.arctan(r2*r3/(r1*np.sqrt(r1**2+r2**2+r3**2)+exp))+\
             (1/6)*(2*r1**2-r2**2-r3**2)*np.sqrt(r1**2+r2**2+r3**2)
     return res
Example #2
0
 def gg(self, r1, r2, r3):
     exp = 10**-18
     res = r1*r2*r3*np.arcsinh(r3/(np.sqrt(r1**2+r2**2)+exp))+\
             (r2/6)*(3*r3**2-r2**2)*np.arcsinh(r1/(np.sqrt(r2**2+r3**2)+exp))+\
             (r1/6)*(3*r3**2-r1**2)*np.arcsinh(r2/(np.sqrt(r1**2+r3**2)+exp))-\
             (r3**3/6)*np.arctan(r1*r2/(r3*np.sqrt(r1**2+r2**2+r3**2)+exp))-\
             (r3*r2**2/2)*np.arctan(r1*r3/(r2*np.sqrt(r1**2+r2**2+r3**2)+exp))-\
             (r3*r1**2/2)*np.arctan(r2*r3/(r1*np.sqrt(r1**2+r2**2+r3**2)+exp))-\
             r1*r2*np.sqrt(r1**2+r2**2+r3**2)/3
     return res
Example #3
0
def asinh(x: Array, /) -> Array:
    """
    Array API compatible wrapper for :py:func:`np.arcsinh <numpy.arcsinh>`.

    See its docstring for more information.
    """
    if x.dtype not in _floating_dtypes:
        raise TypeError("Only floating-point dtypes are allowed in asinh")
    return Array._new(np.arcsinh(x._array))
Example #4
0
def arccsch__(z):
    return cp.arcsinh(1.0/z)
Example #5
0
    def __init__(self,
                 name="none",
                 N=100,
                 H=1,
                 T=273.15,
                 D=2,
                 J=1.21 * np.power(10.0, -21),
                 randomFill=True,
                 K=1.38064852 * np.power(10.0, -23),
                 M=2.22 * np.power(10.0, (-23))):
        self.removeUnderflow = np.power(10, 0)
        self.j = J  # / self.removeUnderflow  # 'numerical' coupling constant
        self.h = H  # external field strength
        self.n = N  # lattice size
        self.m = M  # single spin magnetic moment
        self.k = K  # boltzman constant
        self.t = T  # / self.removeUnderflow # temperature in kelvins
        self.d = D  # system dimension
        self.tc = 2 * J / (K * np.arcsinh(1)
                           )  # theoretical tc for 2d by onsanger
        self.timeStep = 0  # initialize timestep marker
        self.spec = tuple(
            np.ndarray.tolist(np.repeat(np.array([self.n]), self.d)))
        # working
        self.kernel = generate_binary_structure(self.d, 1)
        # not running, need fixing!!!
        self.ground = np.full(self.spec, 0)
        # storage of magnetization time series: timestamp, total magnetization
        self.systemDataTimeSeries = [[], [], []]

        # define the 2d system with or without initial values
        spins = [1, -1]
        if randomFill:
            self.system = np.random.choice(spins, self.spec)
        else:
            # dangerously, for future importing of existing system
            self.system = np.empty(self.spec)
        self.system = np.asarray(self.system)
        choices = list(range(self.n**self.d))

        # warning: optimization only works in odd sized dimensions!!!
        zerothSites = choices[0::4]
        firstSites = choices[1::4]
        secondSites = choices[2::4]
        thirdSites = choices[3::4]

        self.dimensions = range(self.d)

        self.zerothLattice = np.full(self.spec, False)
        for choice in zerothSites:
            self.zerothLattice[tuple([
                int(np.floor(choice % self.n**(x + 1) / self.n**x))
                for x in self.dimensions
            ])] = True

        # self.dimensions = range(self.d)
        self.firstLattice = np.full(self.spec, False)
        for choice in firstSites:
            self.firstLattice[tuple([
                int(np.floor(choice % self.n**(x + 1) / self.n**x))
                for x in self.dimensions
            ])] = True

        # self.dimensions = range(self.d)
        self.secondLattice = np.full(self.spec, False)
        for choice in secondSites:
            self.secondLattice[tuple([
                int(np.floor(choice % self.n**(x + 1) / self.n**x))
                for x in self.dimensions
            ])] = True

        # self.dimensions = range(self.d)
        self.thirdLattice = np.full(self.spec, False)
        for choice in thirdSites:
            self.thirdLattice[tuple([
                int(np.floor(choice % self.n**(x + 1) / self.n**x))
                for x in self.dimensions
            ])] = True
        # print(self.thirdLattice)
        # in each step randomly update all sublattices
        self.sublattices = np.array([
            np.asnumpy(self.zerothLattice),
            np.asnumpy(self.firstLattice),
            np.asnumpy(self.secondLattice),
            np.asnumpy(self.thirdLattice)
        ])

        # self.evenLattice = np.invert(copy.deepcopy(self.oddLattice))
        # iniitalize initial energies using initial state
        self.updateEnergies()

        # save initial system data at time stamp=0
        self.systemDataTimeSeries[0].append(self.timeStep)
        self.systemDataTimeSeries[1].append(self.totalMagnetization())
        # care: coordination number normalization when accounting for total energy
        self.systemDataTimeSeries[2].append(
            np.sum(self.interactionEnergies) / 2)