Beispiel #1
0
    // Calculate matrix element of a coulomb potential given the charges
    // of the elements
    public double coulombPotentialEnergy(matrix A, matrix B)
    {
        double epsilon_0 = 1; // Unit is set to 1 maight want to make static units
        /* int N = problem.getNumberOfParticles() - 1; // For easier readability */
        int    N      = problem.getNumberOfParticles();
        double result = 0;


        matrix inverse = new QRdecomposition(A + B).inverse();
        // For every particle pair (only counting once) calculate interaction
        List <Particle> particles = problem.getParticles();
        matrix          Uinv      = problem.getUInverse();

        for (int j = 0; j < N; j++)
        {
            for (int i = 0; i < j; i++)
            {
                double p_ij = 0;
                for (int k = 0; k < N - 1; k++)
                {
                    for (int l = 0; l < N - 1; l++)
                    {
                        double b_ijk = Uinv[i, k] - Uinv[j, k];
                        double b_ijl = Uinv[i, l] - Uinv[j, l];
                        p_ij += b_ijk * inverse[k, l] * b_ijl;
                    }
                }
                /* result +=  particles[i].getCharge() * particles[j].getCharge() / (4 * Math.PI * epsilon_0) * Math.Sqrt(2 / (p_ij * Math.PI)) * overlapElement(A,B); */
                result += particles[i].getCharge() * particles[j].getCharge() * 2.0 / epsilon_0 * Math.Sqrt(1 / (p_ij * Math.PI * 2)) * overlapElement(A, B);
            }
        }

        return(result);
    }
Beispiel #2
0
    // Generate a list of permutations taking distinguishable particles into
    // account. That is protons and electrons won't be swapped
    public List <Permutation> permutations()
    {
        // Generate List of List of indistinguishable particles
        List <List <int> > listlist = new List <List <int> >();
        List <int>         tmplist  = new List <int>();
        Particle           p        = problem.getParticles()[0];

        tmplist.Add(0);
        for (int i = 1; i < nParticles; i++)
        {
            if (problem.getParticles()[i].equals(p))
            {
                tmplist.Add(i);
            }
            else
            {
                listlist.Add(new List <int>(tmplist));
                tmplist = new List <int>();
                tmplist.Add(i);
                p = problem.getParticles()[i];
            }
            if (i == nParticles - 1)
            {
                listlist.Add(new List <int>(tmplist));
            }
        }

        // Generate List of List of permutations
        List <List <Permutation> > llp = new List <List <Permutation> >();

        foreach (List <int> list in listlist)
        {
            List <Permutation> permu = new List <Permutation>();
            permu.Add(new Permutation(list, 1, -1)); // Need to change last parameter if boson
            llp.Add(Misc.permutations(permu));
        }

        // List containing all previous permutations
        List <Permutation> lp = new List <Permutation>();

        for (int i = llp.Count - 1; i > -1; i--)
        {
            List <Permutation> tmp = new List <Permutation>();
            foreach (Permutation per in llp[i])
            {
                Permutation clone = per.Clone();
                if (lp.Count == 0)
                {
                    tmp.Add(clone);
                }
                foreach (Permutation peru in lp)
                {
                    Permutation clone2 = per.Clone();
                    clone2.Append(peru);
                    tmp.Add(clone2);
                }
            }
            lp = new List <Permutation>(tmp);
        }
        return(lp);
    }