コード例 #1
0
ファイル: Extension.cpp プロジェクト: MPolovyi/SCOLSS
extern "C" void Function_GetChainOrientationProbabilityAngle(int*breaks_counts,
                                                             int*chain_counts,
                                                             char ** input_string,
                                                             int*_ptCount,
                                                             double*  _angleCutOff,
                                                             double* _distanceCutOff) {

    int ptCount = _ptCount[0];
    double angleCutOff = _angleCutOff[0];
    double distanceCutOff = _distanceCutOff[0];

    std::vector<CParticleBase> particles = LoadParticles(*input_string, ptCount);

    int chainLength = 0;

    for (int i = 0; i < particles.size(); i++) {
        auto cosThis = particles[i].GetOrientation().Z;
        auto cosNext = particles[get_next(i, ptCount)].GetOrientation().Z;

        if ((MapOrientation(cosThis, cosNext, angleCutOff) == 0 || MapOrientation(cosThis, cosNext, angleCutOff) == 4)
            && particles[i].GetDistanceRight(particles[get_next(i, ptCount)], 10000).GetLength() < distanceCutOff) {
            chainLength++;
        } else {
            chain_counts[chainLength]++;
            breaks_counts[MapOrientation(cosThis, cosNext, angleCutOff)]++;
        }

    }
}
コード例 #2
0
ファイル: Extension.cpp プロジェクト: MPolovyi/SCOLSS
extern "C" void Function_AutoCorrelationInCluster(double *_averAutoCorr,
                                                  char ** zero_configuration,
                                                  char ** current_configuration,
                                                  int * _ptCount,
                                                  int * _ptIndexes,
                                                  int * _ptIndexCount){

    auto zero_config = LoadParticles(*zero_configuration, *_ptCount);
    auto current_config = LoadParticles(*current_configuration, *_ptCount);

    double corrs = 0;

    for (int i = 0; i < *_ptIndexCount; ++i) {
        corrs += zero_config[_ptIndexes[i]].GetOrientation().DotProduct(current_config[_ptIndexes[i]].GetOrientation());
    }

    *_averAutoCorr = corrs/((double)*_ptIndexCount);
}
コード例 #3
0
ファイル: Extension.cpp プロジェクト: MPolovyi/SCOLSS
extern "C" void Function_AutoCorrelation(double * averAutoCorr,
                                         int* sampleIndex,
                                         char ** zero_configuration,
                                         char ** current_configuration,
                                         int *_ptCount) {
    int ptCount = *_ptCount;

    auto zero_config = LoadParticles(*zero_configuration, ptCount);
    auto current_config = LoadParticles(*current_configuration, ptCount);

    double corr = 0;

    for (int i = 0; i < ptCount; ++i) {
        corr += zero_config[i].GetOrientation().DotProduct(current_config[i].GetOrientation());
    }

    averAutoCorr[*sampleIndex] = corr/(double)ptCount;
}
コード例 #4
0
ファイル: Extension.cpp プロジェクト: MPolovyi/SCOLSS
extern "C" void Function_GetParticlesAngles(double * angles_x, double * angles_y, double * angles_z, double * angle_phi, char ** particles, int * _ptCount){
    auto pts = LoadParticles(*particles, *_ptCount);

    for (int i = 0; i < *_ptCount; ++i) {
        angles_z[i] = std::acos(pts[i].GetOrientation().Z);

        angles_y[i] = std::acos(pts[i].GetOrientation().Y);
        angles_x[i] = std::acos(pts[i].GetOrientation().X);

        angle_phi[i] = std::atan(pts[i].GetOrientation().Y / pts[i].GetOrientation().X);
    }
}
コード例 #5
0
ファイル: Extension.cpp プロジェクト: MPolovyi/SCOLSS
extern "C" void Function_GetDynamicChains(double *neigh_c,
                                          double *coords_first,
                                          int *chained,
                                          char **pts,
                                          int *_strLength,
                                          int *_timePointsCount,
                                          int *_ptCount,
                                          double *_systemSize) {
    int ptCount = _ptCount[0];
    double systemSize = _systemSize[0];
    int ptStringLength = _strLength[0];
    int chainedCutOff = chained[0];

    std::vector<std::vector<CParticleBase>> particles;

    std::string pts_i(ptStringLength, 0);

    for (int k = 0; k < _timePointsCount[0]; ++k) {
        strncpy(&pts_i[0], &pts[0][k * ptStringLength], ptStringLength);

        particles.push_back(LoadParticles(&pts_i[0], ptCount));
    }

    for (int i = 0; i < ptCount; ++i) {
        int next_index = get_next(i, ptCount);

        double dot = 0;
        CVector vec_i;
        CVector vec_j;

        for (int j = 0; j < _timePointsCount[0]; ++j) {
            dot += particles[j][i].GetOrientation().DotProduct(particles[j][next_index].GetOrientation());

            vec_i += particles[j][i].GetOrientation();
            vec_j += particles[j][next_index].GetOrientation();
        }

        neigh_c[i] = dot/_timePointsCount[0] - (vec_i/_timePointsCount[0]).DotProduct((vec_j/_timePointsCount[0]));

        if(neigh_c[i] < chainedCutOff){
            chained[i] = particles[0][i].GetOrientation().Z * particles[0][next_index].GetOrientation().Z > 0;
        }

        coords_first[i] = particles[0][i].Coordinates;
    }
}
コード例 #6
0
ファイル: Extension.cpp プロジェクト: MPolovyi/SCOLSS
extern "C" void Function_GetCorrelations(double *correlations_out,
                                         int *corr_counts_out,
                                         double *corr_lengths_out,
                                         char **input_string,
                                         int *_ptCount,
                                         int *_corrCount,
                                         double *_systemSize) {
    const int& ptCount = *_ptCount;
    const int& corrCount = *_corrCount;
    const double& maxCorrLength = corr_lengths_out[corrCount-1];
    const double& systemSize = *_systemSize;

    std::vector<CParticleBase> particles = LoadParticles(*input_string, ptCount);

    double dist = 0;
    for (int i = 0; i < ptCount; i++) {
        auto& pt = particles[i];

        int j = get_next(i, ptCount);

        auto cosTheta1 = pt.GetOrientation().Z;

        correlations_out[0] += cosTheta1*cosTheta1;
        corr_counts_out[0]++;
        while (j != i) {
            const auto& pt_next = particles[j];

            dist = pt.GetDistanceRight(pt_next, systemSize).GetLength();
            if(dist < maxCorrLength) {
                auto nIndex = get_nearest_index(corr_lengths_out, dist, corrCount);

                auto cosTheta2 = pt_next.GetOrientation().Z;

                correlations_out[nIndex] += cosTheta1 * cosTheta2;
                corr_counts_out[nIndex]++;

                j = get_next(j, ptCount);
            }
            else{
                break;
            }
        }
    }
}
コード例 #7
0
ファイル: World_Setup.cpp プロジェクト: wrdn/SeasonalGlobe
bool World::Load()
{
	conf.ParseConfigFile("Data/ConfigFile.txt"); // load configuration file
	
	// Order of loading: Lights -> Textures -> Shaders -> Geometry -> Particles -> Seasons

	LoadLights();
	LoadTextures();
	LoadSounds();
	LoadShaders();
	LoadGeometry();
	LoadParticles();
	
	SetupSeasons();
	
	//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Color::BLACK.GetVec());
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Color::WHITE.GetVec());

	SetLightingMode(Spotlights);

	return true;
};
コード例 #8
0
ファイル: Extension.cpp プロジェクト: MPolovyi/SCOLSS
extern "C" void Function_GetChainOrientationProbabilityCorrelation(char ** input_string,
                                                              int*_ptCount,
                                                              double*_correlationCutOff,
                                                              int* corr_counts_out,
                                                              double* corr_lengths_out,
                                                              double* _systemSize) {
    int ptCount = _ptCount[0];
    double correlationCutOff = _correlationCutOff[0];
    double systemSize = _systemSize[0];

    auto particles = LoadParticles(*input_string, ptCount);

    bool chain_1;
    bool chain_2;

    int chainLength = 0;

    for (int i = 0; i < particles.size(); i++) {
        auto& pt = particles[i];
        chain_1 = pt.GetOrientation().Z > 0;
        auto& pt_next = particles[get_next(i, ptCount)];

        auto cosTheta = pt.GetOrientation().Z;
        auto cosTheta_next = pt_next.GetOrientation().Z;

        chain_2 = cosTheta_next > 0;

        double relCos = cosTheta*cosTheta_next;

        if(std::abs(relCos) > correlationCutOff) {
            chainLength++;
        }
        else {
            // rr, lr, rl, ll
            if (chain_1 && chain_2) {
                corr_counts_out[0]++;
                corr_lengths_out[0] += pt.GetDistanceRight(pt_next, systemSize).GetLength();

                corr_lengths_out[4] += relCos;
            }
            if (!chain_1 && chain_2) {
                corr_counts_out[1]++;
                corr_lengths_out[1] += pt.GetDistanceRight(pt_next, systemSize).GetLength();

                corr_lengths_out[5] += relCos;
            }
            if (chain_1 && !chain_2) {
                corr_counts_out[2]++;
                corr_lengths_out[2] += pt.GetDistanceRight(pt_next, systemSize).GetLength();

                corr_lengths_out[6] += relCos;
            }
            if (!chain_1 && !chain_2) {
                corr_counts_out[3]++;
                corr_lengths_out[3] += pt.GetDistanceRight(pt_next, systemSize).GetLength();

                corr_lengths_out[7] += relCos;
            }

            if (chain_1) {
                corr_counts_out[4]++;
            }
            else {
                corr_counts_out[5]++;
            }

            corr_counts_out[6] += chainLength;
            chainLength = 0;
        }
    }
}
コード例 #9
0
ファイル: H5hut-io.cpp プロジェクト: ajakobs/iPic3D
void H5input::ReadParticles(int rank, int nproc, const int *dimns, double *L, MPI_Comm CART_COMM){
  int ndim = 3; // By default 2D is considered as a 'flat' 3D
  LoadParticles(ndim, rank, nproc, dimns, L, CART_COMM);
  InitParticles(ndim, rank, CART_COMM);
}