__inline k_t random_spp_wavevector(double k_spp_abs, gsl_rng *r) {
    k_t k;
    double theta = random_double_range(r, 0.0, 2.0*M_PI);
    k.kz = 0.0;
    k.kx = k_spp_abs * sin(theta);
    k.ky = k_spp_abs * cos(theta);
    return k;
}
Exemple #2
0
k_t random_spp_wavevector(double k_spp_abs, double k_light,gsl_rng *r){
k_t k;
double k_abs = 0.0;
double sigma = 0.016*k_spp_abs;
double theta = random_double_range(r, 0.0, 2.0*M_PI);
k_abs = k_spp_abs + gsl_ran_gaussian(r, sigma);
k.kz = sqrt(k_light*k_light - k_abs*k_abs);
//printf("%g %g\n",k_spp_abs,k_abs);
k.kx = k_abs * sin(theta);
k.ky = k_abs * cos(theta);
return k;
}
/*
 * this is the method to create the index of the next scatter */
__inline int next_scatter_index(int current_index,int NSCAT, gsl_rng *r, index_bounds *matrix) {
    int next_scatter_index,i;
    double random_probability = 0.0;
    random_probability = random_double_range(r, 0.0, 1.0);
    for (i = 0; i < NSCAT-1; ++i) {
        if (random_probability<=matrix[i].upper_bound && random_probability > matrix[i].lower_bound) {
            next_scatter_index = matrix[i].index;
            break;
        }
    }
    return next_scatter_index;
}
/**
 *
 * This is the method to create the exponential probability function for the spp multiple scattering.
 *
 */
__inline bool is_radiation_out(double pathlength, double mean_free_pathlength,gsl_rng *r) {
    double random_probability = 0.0;
    double out_probability = 0.0;
    bool out = false;
    random_probability = random_double_range(r, 0.0, 1.0);
    out_probability = cexp(-(pathlength/mean_free_pathlength));
    if(random_probability >= out_probability) {
        out = true;
    }
    else {
        out = false;
    }
    return out;
}
Exemple #5
0
GAULFUNC double random_cauchy(void)
  {
  return tan(random_double_range(-PI/2,PI/2));
  }
Exemple #6
0
double random_double_range_wrapper(double *min, double *max)
  {
  return random_double_range(*min, *max);
  }
Exemple #7
0
bool
initialChromo2( population *pop, entity *adam ){

	int		point;		/* Index of allele to seed */

	/* Checks. */
	if (!pop) die("Null pointer to population structure passed.");
	if (!adam) die("Null pointer to entity structure passed.");

	/* Seeding. */
	bool		success = false;
	while( !success ){

		// rotate angle
		for (point=7; point<pop->len_chromosomes; point++)
		{
			((double *)adam->chromosome[0])[point]
			                               = (double)random_double( 360 );
		}

		//------------------------------------------- rotate ligand ------------------------------------------------------
		Molecular						rotateLig = ligand ;
		Molecular						tempMol ;
		vector<Molecular>		rotateVec;
		rotateVec.push_back( rotateLig );
		for( int  k=7; k< pop->len_chromosomes; k++ ){
			double	rotateAngle = ((double*)adam->chromosome[0])[k];

			Molecular					mole = rotateAroundBond( rotateVec.back(),
					rotableBondVec[k-7].get_firstAtomIndex(),
					rotableBondVec[k-7].get_secAtomIndex(), rotateAngle );
//			mole.print();
			rotateVec.push_back( mole );
		}
		Molecular			finalLig = rotateVec.back();
		//---------------------------------------------------------------------------------------------------------------------

		size_t				count = 0;
		while( count < 1000  ){
			count ++;
//			cout<<" "<<count;
			for (point=0; point<3; point++)
			{
				((double *)adam->chromosome[0])[point]
				                               = ( double )random_double( 360 );
			}
			Molecular			newLig 	 ;
			Molecular			newLig2 ;
			double	rotateX =	((double*)adam->chromosome[0])[0];
			double	rotateY =		((double*)adam->chromosome[0])[1];
			double	rotateZ =	((double*)adam->chromosome[0])[2];
			newLig = rotateAroundAtom( finalLig, rotateCenterAtomIndex, rotateX, rotateY, rotateZ );

			for (point=3; point<7; point++)
			{
				((double *)adam->chromosome[0])[point]
				                               = (double)random_double_range( -0.0, 0.0 );
			}
			double 	transX = 		((double*)adam->chromosome[0])[3];
			double 	transY = 		((double*)adam->chromosome[0])[4];
			double 	transZ = 		((double*)adam->chromosome[0])[5];
			double	transDis = 	((double*)adam->chromosome[0])[6];
			Coord	trans( transX, transY, transZ );
			newLig2 = translateMol( newLig, trans, transDis );


			if( ! atomsCrash( bindingAtomVec, newLig2.get_atomVec() ) ){
				cout<<"-----------------------------------------------------------"<<endl;
				if( 1 ){
					for( int  k=0; k< pop->len_chromosomes; k++ ){
						cout.width(12);
						cout<<left<<((double*)adam->chromosome[0])[k];
					}
					cout<<endl;
				}
//				newLig2.print();
				success = true;
				break;
			}
		}
	}
	return true;
}