Esempio n. 1
0
    public void Test_number_of_nonlinear_parameters()
    {
        int n            = problem.getNumberOfParticles();
        int lengthAlphas = svm.makeAlphas().Count;

        Assert.AreEqual(n * (n - 1) / 2, lengthAlphas);
    }
Esempio n. 2
0
 public SVM(ProblemSetup problem)
 {
     this.problem = problem;
     nParticles   = problem.getNumberOfParticles();
     mef          = new MEF(problem);
     /* perms = permutations(); */
 }
Esempio n. 3
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);
    }