<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package etomica.virial;

import java.math.BigDecimal;

/**
 * Cluster class using Whealtey's recursion with BigDecimal to handle mixtures.
 * 
 * @author <NAME>
 */
public class ClusterWheatleySoftBDMix extends ClusterWheatleySoftBD {

    protected final MayerFunction[][] mixF;
    protected final int[] nTypes;
    protected final MayerFunction[][] fMap;
    
    public ClusterWheatleySoftBDMix(int nPoints, int[] nTypes, MayerFunction[][] f, int precision) {
        super(nPoints, null, precision);
        this.nTypes = nTypes;
        mixF = f;
        fMap = new MayerFunction[nPoints][nPoints];
        int iType = 0, jType = 0;
        int iSum = nTypes[0], jSum = 0;
        for (int i=0; i<nPoints; i++) {
            while (i>iSum) {
                iType++;
                iSum += nTypes[iType];
            }
            jSum = iSum;
            jType = iType;
            for (int j=i+1; j<nPoints; j++) {
                while (j>jSum) {
                    jType++;
                    jSum += nTypes[jType];
                }
                fMap[i][j] = f[iType][jType];
            }
        }
                
    }
    
    public ClusterAbstract makeCopy() {
        ClusterWheatleySoftMix c = new ClusterWheatleySoftMix(n, nTypes, mixF, tol);
        c.setTemperature(1/beta);
        return c;
    }

    protected void updateF(BoxCluster box) {
        CoordinatePairSet cPairs = box.getCPairSet();
        AtomPairSet aPairs = box.getAPairSet();

//        f.setBox(box);
        // recalculate all f values for all pairs
        for(int i=0; i<n-1; i++) {
            for(int j=i+1; j<n; j++) {
                double ff = fMap[i][j].f(aPairs.getAPair(i,j),cPairs.getr2(i,j), beta);
//                if (Math.abs(ff) < 1e-14) ff = 0;
                fQ[(1<<i)|(1<<j)] = new BigDecimal(ff).add(BDONE, mc);
            }
        }
    }

}
<commit_msg>set box here too set fMap like ClusterWheatleySoftMix does<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package etomica.virial;

import java.math.BigDecimal;

/**
 * Cluster class using Whealtey's recursion with BigDecimal to handle mixtures.
 * 
 * @author <NAME>
 */
public class ClusterWheatleySoftBDMix extends ClusterWheatleySoftBD {

    protected final MayerFunction[][] mixF;
    protected final int[] nTypes;
    protected final MayerFunction[][] fMap;
    
    public ClusterWheatleySoftBDMix(int nPoints, int[] nTypes, MayerFunction[][] f, int precision) {
        super(nPoints, null, precision);
        this.nTypes = nTypes;
        mixF = f;
        fMap = new MayerFunction[nPoints][nPoints];
        int iType = 0, jType = 0;
        int iSum = nTypes[0], jSum = 0;
        for (int i=0; i<nPoints; i++) {
            while (i>=iSum) {
                iType++;
                iSum += nTypes[iType];
            }
            jSum = iSum;
            jType = iType;
            for (int j=i+1; j<nPoints; j++) {
                while (j>=jSum) {
                    jType++;
                    jSum += nTypes[jType];
                }
                fMap[i][j] = f[iType][jType];
            }
        }
                
    }
    
    public ClusterAbstract makeCopy() {
        ClusterWheatleySoftMix c = new ClusterWheatleySoftMix(n, nTypes, mixF, tol);
        c.setTemperature(1/beta);
        return c;
    }

    protected void updateF(BoxCluster box) {
        CoordinatePairSet cPairs = box.getCPairSet();
        AtomPairSet aPairs = box.getAPairSet();
        for (int i=0; i<mixF.length; i++) {
            for (int j=0; j<mixF[i].length; j++) {
                mixF[i][j].setBox(box);
            }
        }

        // recalculate all f values for all pairs
        for(int i=0; i<n-1; i++) {
            for(int j=i+1; j<n; j++) {
                double ff = fMap[i][j].f(aPairs.getAPair(i,j),cPairs.getr2(i,j), beta);
//                if (Math.abs(ff) < 1e-14) ff = 0;
                fQ[(1<<i)|(1<<j)] = new BigDecimal(ff).add(BDONE, mc);
            }
        }
    }

}

{'fraction_non_alphanumeric': 0.1276498746295874, 'fraction_numerical': 0.01002963300661044, 'mean_word_length': 1.8364576599870717, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3432554', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1417, 'n_words': 368}