Пример #1
0
    void ClusterPruner::prune(const std::list<std::shared_ptr<Cluster> > &clusters) {
        
        _clusters.clear();
        
        
        // Calculate the mean size of clusters.
        //MeanSequentialEstimator mean_estimator;
        std::set<int>   taken_ids;
        for (const auto& c : clusters) {
          //  mean_estimator.Add(c->size());
            taken_ids.insert(c->ClusterID());
        }
        
        // Only split clusters whose size is above the mean cutoff.
        //size_t mean_cutoff = static_cast<int>(mean_estimator.GetMean());
 	    std::cout << "Split threshold for post prunning is " << _split_size << std::endl;
        std::shared_ptr<IDGenerator> id_pool(new IDGenerator(taken_ids));
        std::list<std::vector<double>> entropies;
        ClusterSplitter splitter(_recalibrator, id_pool);
        for (const auto& c : clusters) {
            if (c->size() <= _split_size) {
                _clusters.push_back(c);
                entropies.push_back(Entropy(c->bpFrequency()));
            } else {
                vector<shared_ptr<Cluster>> splited_clusters = splitter.split(c);
                for (const auto& s : splited_clusters) {
                    if (s.get()) {
                        _clusters.push_back(s);
                        entropies.push_back(Entropy(s->bpFrequency()));
                    }
                }
            }
        }
        // Merge cluster who has the same centers.
        MergeByCenters merger(_recalibrator);
        merger.merge(_clusters, entropies);
        _clusters = merger.clusters();
        // Filter out cluster
        // 3.Remove those clusters whose size is below the cutoff.
        list<shared_ptr<Cluster>> filtered_clusters;
        for (const auto& c : _clusters) {
            if (c->size() >= this->_cutoff) {
                filtered_clusters.push_back(c);
            }
        }
        //_clusters = std::move(filtered_clusters);
        std::swap(_clusters, filtered_clusters);

    }
Пример #2
0
void OpenSMOKE_GasStream::lock()
{
	if (assignedKineticScheme == false)
		ErrorMessage("The kinetic scheme was not defined!!");
	if (assignedMassFlowRate == false && assignedMoleFlowRate == false && assignedVolumetricFlowRate == false)
	{
		//	ErrorMessage("The flow rate was not defined!!");
		AssignMassFlowRate(1.e-10, "kg/s");
		iUndefinedFlowRate = true;
	}
	if (assignedMoleFractions == false && assignedMassFractions == false)
		ErrorMessage("The composition was not defined!!");

	Composition();

	if (assignedTemperature == true && assignedPressure == true && assignedDensity == true)
		ErrorMessage("Only 2 between: T || P || rho");
	if (assignedTemperature == true && assignedPressure == true)
		{ /* Nothing to do */						}
	else if (assignedDensity == true && assignedPressure == true)
		{	T = P*MW/Constants::R_J_kmol/rho;	}
	else if (assignedDensity == true && assignedTemperature == true)
		{	P = rho*Constants::R_J_kmol*T/MW;	}
	else ErrorMessage("2 between must be assigned: T || P || rho");
		
	Concentrations();
	Density();
	FlowRates();
	SpecificEnthalpies();
	Enthalpy();
	SpecificEntropies();
	Entropy();
}
Пример #3
0
SeedSelector::SeedSelector(size_t barcode_length) : _barcode_length(barcode_length) {
    _entropy_threshold = Entropy({95,5,0,0});
    _dict = kmersDictionary::getAutoInstance();
    assert(_dict.get());
    _position_weight_matrix.assign(barcode_length, {0,0,0,0});
    _entropy.assign(barcode_length, 0);
}
Пример #4
0
//Histogram *Unser(Image *img)
float *Unser(Image *img)
{
  Histogram *h = NULL;
  float sum[4][511], dif[4][511], *val=NULL;
  float mean, contrast, correlation;
  int i;

  val = (float*) calloc(SIZE,sizeof(float));

  ComputeHistograms(img, sum, dif);

  for (i=0; i<4; i++){
    mean = Mean(sum[i]);
    val[i * 8 + 0] = mean;
    contrast = Contrast(dif[i]);
    val[i * 8 + 1] = contrast;// / 255.0;
    correlation = Correlation(sum[i], mean, contrast);
    val[i * 8 + 2] = (correlation);// + 32512.5) / 255.0;
    val[i * 8 + 3] = Energy(sum[i], dif[i]);// * 255.0 ;
    val[i * 8 + 4] = Entropy(sum[i], dif[i]);// * 255.0 / 5.4168418;
    val[i * 8 + 5] = Homogeneity(dif[i]);// * 255.0;
    val[i * 8 + 6] = MaximalProbability(sum[i]);// * 255.0;
    val[i * 8 + 7] = StandardDeviation(contrast, correlation);// *sqrt(2);
  }

  //h = CreateHistogram(SIZE);
  //LinearNormalizeHistogram(h->v, val, 255.0, SIZE);

  //return(h);
  return(val);
}
Пример #5
0
EXPORT	void	fprint_raw_gas_data(
	FILE		*file,
	Locstate	state,
	int		dim)
{
	(void) fprintf(file,"state 0x%p\n",(POINTER)state);
	if (state == NULL)
	{
	    (void) printf("NULL state\n");
	    return;
	}
	(void) fprintf(file,"\tState Data ");
	(void) fprintf(file,"\n");
	switch (state_type(state))
	{
	case GAS_STATE:
	    g_fprint_raw_state(file,state,dim);
	    break;

	case EGAS_STATE:
	    g_fprint_raw_Estate(file,state,dim);
	    break;

	case TGAS_STATE:
	    g_fprint_raw_Tstate(file,state,dim);
	    break;

	case FGAS_STATE:
	    g_fprint_raw_Fstate(file,state,dim);
	    break;

	case OBSTACLE_STATE:
	    (void) fprintf(file,"Obstacle state type,  "
				"printing as GAS_STATE\n");
	    g_fprint_raw_state(file,state,dim);
	    break;

	case VGAS_STATE:
	    g_fprint_raw_Tstate(file,state,dim);
	    (void) printf("Specific internal energy = %"FFMT"\n",Int_en(state));
	    (void) printf("Entropy = %"FFMT"\n",Entropy(state));
	    (void) printf("Sound_speed = %"FFMT"\n",sound_speed(state));
#if defined(VERBOSE_GAS_PLUS)
	    (void) printf("Enthalpy = %"FFMT"\n",Enthalpy(state));
	    (void) printf("Temperature = %"FFMT"\n",Temp(state));
#endif /* defined(VERBOSE_GAS_PLUS) */
	    break;

	case UNKNOWN_STATE:
	    (void) fprintf(file,"Unknown state type,  printing as GAS_STATE\n");
	    g_fprint_raw_state(file,state,dim);
	    break;

	default:
	    screen("ERROR in fprint_raw_gas_data(), "
	           "unknown state type %d\n",state_type(state));
	    clean_up(ERROR);
	}
}		/*end fprint_raw_gas_data*/
Пример #6
0
void TerraformPrepare () 
{


  int         x, y;
  Region      r;
  GLcoord     from_center;
  GLcoord     offset;

  //Set some defaults
  offset.x = RandomVal () % 1024;
  offset.y = RandomVal () % 1024;
  for (x = 0; x < WORLD_GRID; x++) {
    for (y = 0; y < WORLD_GRID; y++) {
      memset (&r, 0, sizeof (Region));
      sprintf (r.title, "NOTHING");
      r.geo_bias = r.geo_detail = 0;
      r.mountain_height = 0;
      r.grid_pos.x = x;
      r.grid_pos.y = y;
      r.tree_threshold = 0.15f;
      from_center.x = abs (x - WORLD_GRID_CENTER);
      from_center.y = abs (y - WORLD_GRID_CENTER);
      //Geo scale is a number from -1 to 1. -1 is lowest ocean. 0 is sea level. 
      //+1 is highest elevation on the island. This is used to guide other derived numbers.
      r.geo_scale = glVectorLength (glVector ((float)from_center.x, (float)from_center.y));
      r.geo_scale /= (WORLD_GRID_CENTER - OCEAN_BUFFER);
      //Create a steep drop around the edge of the world
      if (r.geo_scale > 1.0f)
        r.geo_scale = 1.0f + (r.geo_scale - 1.0f) * 4.0f;
      r.geo_scale = 1.0f - r.geo_scale;
      r.geo_scale += (Entropy ((x + offset.x), (y + offset.y)) - 0.5f);
      r.geo_scale += (Entropy ((x + offset.x) * FREQUENCY, (y + offset.y) * FREQUENCY) - 0.2f);
      r.geo_scale = clamp (r.geo_scale, -1.0f, 1.0f);
      if (r.geo_scale > 0.0f)
        r.geo_water = 1.0f + r.geo_scale * 16.0f;
      r.color_atmosphere = glRgba (0.0f, 0.0f, 0.0f);
      r.geo_bias = 0.0f;
      r.geo_detail = 0.0f;
      r.color_map = glRgba (0.0f);
      r.climate = CLIMATE_INVALID;
      WorldRegionSet (x, y, r);
    }
  }

}
Пример #7
0
double infoGain(vector<vector<int> >& al) {
   int total_l0=0, total_l1=0;
   vector<double> Es(al.size(),0);
   for(int a = 0; a < al.size(); a++) {
      total_l0 += al[a][0];
      total_l1 += al[a][1];
      Es[a] = Entropy(al[a][0],al[a][1]);
   }
   int total = total_l0 + total_l1;
   double E = Entropy(total_l0,total_l1);
   double IG = E;
   for(int a = 0; a < al.size(); a++) {
      IG -= (Es[a] * (double)(al[a][0]+al[a][1])/(double)total);
   }
   if(IG < 1e-5 || IG != IG) IG = 0;
   //cerr << IG << "," << E << "," << Es[0] << "," << Es[1] << endl;
   return IG;
}
float Information::ComputeInformation()
{
	if (classes.empty())
	{
		return 0.0f;
	}
	Entropy entropy = Entropy();
	for each (int var in classes)
	{
		entropy.AddProbability(static_cast<float>(var) / static_cast<float>(sum));
	}
Пример #9
0
void OpenSMOKE_GasStream::ChangeMoleFractions(BzzVector &_values)
{
	AssignMoleFractions(_values);

	Composition();
	Concentrations();
	Density();
	FlowRates();
	SpecificEnthalpies();
	Enthalpy();
	SpecificEntropies();
	Entropy();
}
Пример #10
0
void OpenSMOKE_GasStream::ChangeTemperature(const double _value, const std::string _units)
{
	if (_value<=0.)
		ErrorMessage("The temperature must be greater than zero!");

	T = OpenSMOKE_Conversions::conversion_temperature(_value, _units);

	Concentrations();
	Density();
	FlowRates();
	SpecificEnthalpies();
	Enthalpy();
	SpecificEntropies();
	Entropy();
}
Пример #11
0
int main( int argc, char* argv[] )
{
    if( argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " <InputImage>" << std::endl;
        return EXIT_FAILURE;
    }

    cv::Mat image = cv::imread( argv[1] );
    if(!image.data)
    {
        return EXIT_FAILURE;
    }

    cv::Scalar ent; //0:1st channel, 1:2nd channel and 2:3rd channel

    ent=Entropy(image);

    std::cout<<"Entropy: "<<ent.val[0]<<std::endl;

    return 0;
}
Пример #12
0
int main(int argc, char ** argv){
  // ./a.out Nx
  FILE * fid1, * fid2, * fid3;
  fid1 = fopen("initial2.dat", "w");
  fid3 = fopen("entropy.dat", "w");
  double T = atof(argv[1]); double t = 0; 
  double L = 1.;   int Nx = 5000; double dx = L/(double)Nx;int NT = Nx + 2;
  double **U; double rho[Nx+2]; double P[Nx+2];double V[Nx+2];
  initnxN(&U, Nx+2, 3);
  initialize_system(U, rho, P, V, NT);
  //printf("i write=%f\n", U[0][NT-2]);
  double dense[Nx]; getRow(U, NT, dense, 0);
  write(dense, fid1, NT, dx);


  //advance_system( U , dx , t , NT , P );
  //printf("t=%f\n", t); 
  //sleep(1);
  
  while(t<T){
    double tn = advance_system(U, dx, t, NT, P); 
    double sumv, sump;
    Entropy(U, NT, dx, &sumv, &sump);
    fprintf(fid3, "%e   %e   %e\n", t, sumv, sump);
    //printf("t=%f\n", tn); 
    //sleep(1);
    t = tn;
    //printf("i 21 column %f  %f  %f", U[0][21], U[1][21], U[2][21]);
    //break;

    }
  fid2 = fopen("final2.dat", "w");
  getRow(U, NT, dense, 0);
  write(dense, fid2, NT, dx);
  
  return(0);
}
Пример #13
0
/* ********************************************************************* */
void ComputeEntropy (const Data *d, Grid *grid)
/*!
 * Compute entropy as a primitive variable.
 *
 * \param [in,out]  d   pointer to Data structure
 * \param [in]    grid  pointer to an array of Grid structures.
 *
 * \return This function has no return value.
 *
 *********************************************************************** */
{
  int i, j, k;
  static double **v1d;

  if (v1d == NULL) v1d = ARRAY_2D(NMAX_POINT, NVAR, double);
  KTOT_LOOP(k) {
  JTOT_LOOP(j) {
    ITOT_LOOP(i) {
      v1d[i][RHO] = d->Vc[RHO][k][j][i];
      v1d[i][PRS] = d->Vc[PRS][k][j][i];
    }
    Entropy(v1d, d->Vc[ENTR][k][j], 0, NX1_TOT-1);
  }}
}
Пример #14
0
cv::Mat getGradImg(cv::Mat src){
    double b_11[9]={0,1,0,1,1,1,0,1,0};
    double b_12[9]={1,0,1,0,1,0,1,0,1};
    double b_21[9]={0,1,0,0,1,0,0,1,0};
    double b_22[9]={0,0,0,1,1,1,0,0,0};
    double b_23[9]={1,0,0,0,1,0,0,0,1};
    double b_24[9]={0,0,1,0,1,0,1,0,0};

    cv::Mat mask_11(3,3,CV_64F,b_11);mask_11.convertTo(mask_11,CV_8U);
    cv::Mat mask_12(3,3,CV_64F,b_12);mask_12.convertTo(mask_12,CV_8U);
    cv::Mat mask_21(3,3,CV_64F,b_21);mask_21.convertTo(mask_21,CV_8U);
    cv::Mat mask_22(3,3,CV_64F,b_22);mask_22.convertTo(mask_22,CV_8U);
    cv::Mat mask_23(3,3,CV_64F,b_23);mask_23.convertTo(mask_23,CV_8U);
    cv::Mat mask_24(3,3,CV_64F,b_24);mask_24.convertTo(mask_24,CV_8U);

    cv::Mat img,img_erod,img_dila;
    cv::Mat grad_11,grad_12,grad_21,grad_22,grad_23,grad_24;
    img=ButFIlt(src);

    cv::imwrite("src_gray.tif",src);
    cv::imwrite("src_butfile.tif",img);

    cv::erode(img,img_erod,mask_11);
    cv::dilate(img,img_dila,mask_11);
    cv::absdiff(img_dila,img_erod,grad_11);

    cv::erode(img,img_erod,mask_12);
    cv::dilate(img,img_dila,mask_12);
    cv::absdiff(img_dila,img_erod,grad_12);

    cv::erode(img,img_erod,mask_21);
    cv::dilate(img,img_dila,mask_21);
    cv::absdiff(img_dila,img_erod,grad_21);

    cv::erode(img,img_erod,mask_22);
    cv::dilate(img,img_dila,mask_22);
    cv::absdiff(img_dila,img_erod,grad_22);

    cv::erode(img,img_erod,mask_23);
    cv::dilate(img,img_dila,mask_23);
    cv::absdiff(img_dila,img_erod,grad_23);

    cv::erode(img,img_erod,mask_24);
    cv::dilate(img,img_dila,mask_24);
    cv::absdiff(img_dila,img_erod,grad_24);

    cv::imwrite("grad_11.tif",grad_11);
    cv::imwrite("grad_12.tif",grad_12);
    cv::imwrite("grad_21.tif",grad_21);
    cv::imwrite("grad_22.tif",grad_22);
    cv::imwrite("grad_23.tif",grad_23);
    cv::imwrite("grad_24.tif",grad_24);

    std::vector<double> h(6,0);
    std::vector<double> w(6,0);

    h[0]=Entropy(grad_11);
    h[1]=Entropy(grad_12);
    h[2]=Entropy(grad_21);
    h[3]=Entropy(grad_22);
    h[4]=Entropy(grad_23);
    h[5]=Entropy(grad_24);

    grad_11.convertTo(grad_11,CV_64F);grad_12.convertTo(grad_12,CV_64F);
    grad_21.convertTo(grad_21,CV_64F);grad_22.convertTo(grad_22,CV_64F);
    grad_23.convertTo(grad_23,CV_64F);grad_24.convertTo(grad_24,CV_64F);

    double sum_1=h[0]+h[1];
    double sum_2=h[2]+h[3]+h[4]+h[5];
    w[0]=h[0]/sum_1;
    w[1]=h[1]/sum_1;
    w[2]=h[2]/sum_2;
    w[3]=h[3]/sum_2;
    w[4]=h[4]/sum_2;
    w[5]=h[5]/sum_2;

    cv::Mat grad_1=w[0]*grad_11+w[1]*grad_12;
    cv::Mat grad_2=w[2]*grad_21+w[3]*grad_22+w[4]*grad_23+w[5]*grad_24;
    cv::Mat grad=grad_1+grad_2;

    cv::normalize(grad,grad,255,0,CV_MINMAX);
    grad.convertTo(grad,CV_8U);
    return grad;
}
Пример #15
0
void RunTests()
{
#pragma mark Vacuum Mass Zeroed Equation

    if (true)
    {
        printf("\tVacuum Mass Zeroed Equation\n");
        SetFilePath("tests/vacuum-mass-equation/data/");

        SetParametersSet(options.parameterization);

		double min_mass = 0.0;
		double max_mass = 1000.0;
		int points_number = 1000;

    	double step = Step(min_mass, max_mass, points_number);

    	FILE * f = OpenFile("vacuum_mass_equation.dat");

		double m = 0;
    	while (m < points_number) {
        	fprintf(f, "%20.15E\t%20.15E\n", m, VacuumMassEquation(m, NULL));
        	m += step;
    	}

    	fclose(f);

        SetFilePath("tests/vacuum-mass-equation/");
        FILE * log_file = OpenFile("run.log");

        fprintf(log_file,
				"The following tests were executed for %s parameterization:\n",
				parameters.parameters_set_identifier);
        fprintf(log_file,
                "\tVacuum mass equation calculation.\n\n");

        PrintParametersToFile(log_file);

        fclose(log_file);

        SetFilePath(NULL);
    }

#pragma mark ZeroedGapEquation
	if (true)
    {
        printf("\tVacuum Mass Zeroed Equation\n");
        SetFilePath("tests/vacuum-mass-equation/data/");

        SetParametersSet(options.parameterization);

		double min_mass = 0.0;
		double max_mass = 1000.0;
		int points_number = 1000;

    	double step = Step(min_mass, max_mass, points_number);
        
        double barionic_density[4] = {parameters.loop_variable.min_value,
                                      parameters.loop_variable.max_value * 1.0 / 3.0,
                                      parameters.loop_variable.max_value * 2.0 / 3.0,
                                      parameters.loop_variable.max_value};
        for (int i = 0; i < 4; i++){
            double fermi_momentum = CONST_HBAR_C
                                    * pow(3.0 * pow(M_PI, 2.0) * barionic_density[i] / NUM_FLAVORS,
                                          1.0 / 3.0);
            char filename[256];
            sprintf(filename, "zeroed_gap_equation_%d.dat", i);

    		FILE * f = OpenFile(filename);

    		gap_equation_input input;
    		input.fermi_momentum = fermi_momentum;

			double m = 0;
    		while (m < max_mass) {
        		fprintf(f, "%20.15E\t%20.15E\n", m, ZeroedGapEquation(m, &input));
        		m += step;
    		}
        }

        SetFilePath("tests/vacuum-mass-equation/");
        FILE * log_file = OpenFile("run.log");
        
        fprintf(log_file,
				"The following tests were executed for %s parameterization:\n",
				parameters.parameters_set_identifier);
        fprintf(log_file,
                "\tZeroed gap equation calculation\n\n");
        
        PrintParametersToFile(log_file);
        
        fclose(log_file);

        SetFilePath(NULL);
    }

#pragma mark Zeroed Renormalized Chemical Potential
	if (true)
    {
        printf("\tVacuum Mass Zeroed Equation\n");
        SetFilePath("tests/vacuum-mass-equation/data/");

        SetParametersSet(options.parameterization);

		double mass = 0;
		double chemical_potential = 0;

		double min_renormalized_chemical_potential = 0.0;
		double max_renormalized_chemical_potential = 1000.0;
		int points_number = 1000;

    	double step = Step(min_renormalized_chemical_potential,
						   max_renormalized_chemical_potential,
						   points_number);

    	FILE * f = OpenFile("zeroed_renorm_chemical_pot_equation.dat");

    	renorm_chem_pot_equation_input input;
    	input.chemical_potential = chemical_potential;
    	input.mass = mass;

		double mu = 0;
    	while (mu < points_number) {
        	fprintf(f,
        	        "%20.15E\t%20.15E\n",
        	        mu,
        	        ZeroedRenormalizedChemicalPotentialEquation(mu, &input));
        	mu += step;
    	}

    	fclose(f);

        SetFilePath("tests/vacuum-mass-equation/");
        FILE * log_file = OpenFile("run.log");

        fprintf(log_file,
				"The following tests were executed for %s parameterization:\n",
				parameters.parameters_set_identifier);
        fprintf(log_file,
				"\tZeroed renormalized chemical potential equation calculation\n\n");

        PrintParametersToFile(log_file);

        fclose(log_file);

        SetFilePath(NULL);
    }

#pragma mark Reproduce Fig. 1 (right) from  M. Buballa, Nuclear Physics A 611
    
    // Reproduce Fig. 1 (right) from  M. Buballa, Nuclear Physics A 611 (1996) 393-408
    // (the figure uses parameters of Set II from the article)
    if (true)
    {
        printf("\tReproduce Fig. 1 (right) from  M. Buballa, Nuclear Physics A 611\n");
        SetFilePath("tests/Buballa-Fig1-R/data/");
        
        SetParametersSet("Buballa_2");

        double chemical_potential[4] = {0.0, 350.0, 378.5, 410.0};

        double vacuum_mass = VacuumMassDetermination();

        double vacuum_thermodynamic_potential = ThermodynamicPotential(vacuum_mass, 0.0, 0.0, 0.0);

        for (int i = 0; i < 4; i++){

            double minimum_mass = 0.0;
            double maximum_mass = 1000.0;
            int points_number = 1000;

            double step = (maximum_mass - minimum_mass) / (points_number - 1);

            gsl_vector * mass_vector = gsl_vector_alloc(points_number);
            gsl_vector * output = gsl_vector_alloc(points_number);

            double m = 0;

            for (int j = 0; j < points_number; j++) {

                double renormalized_chemical_potential = chemical_potential[i];

                double fermi_momentum = 0;
                if (pow(renormalized_chemical_potential, 2.0) > pow(m, 2.0)){
                    fermi_momentum = sqrt(pow(renormalized_chemical_potential, 2.0) - pow(m, 2.0));
                }
                
                double thermodynamic_potential = ThermodynamicPotential(m,
                                                                        fermi_momentum,
                                                                        chemical_potential[i],
                                                                        renormalized_chemical_potential);
                gsl_vector_set(mass_vector, j, m);
                gsl_vector_set(output, j, thermodynamic_potential - vacuum_thermodynamic_potential);
                
                m += step;
            }

            char filename[256];
            sprintf(filename, "Fig1_Buballa_%d.dat", i);
            
            WriteVectorsToFile(filename,
                               "# mass, thermodynamic potential\n",
                               2,
                               mass_vector,
                               output);
        }
        
        SetFilePath("tests/Buballa-Fig1-R/");
        FILE * log_file = OpenFile("run.log");
        fprintf(log_file,
                "The following tests were executed for %s parameterization:\n",
                parameters.parameters_set_identifier);
        fprintf(log_file, "\tCalculation of vacuum mass, resultin in %f MeV.\n", vacuum_mass);
        fprintf(log_file,
                "\tCalculation of the thermodynamic potential as function of mass "
                "(Reproduce Fig. 1 (right) from  M. Buballa, Nuclear Physics A 611 (1996) 393-408).\n"
                "\tfiles: tests/data/Fig1_Buballa_*.dat\n");
        
        PrintParametersToFile(log_file);
        
        fclose(log_file);

        SetFilePath(NULL);
    }
    
#pragma mark Reproduce Fig. 2.8 (left) from  M. Buballa, Physics Reports

    // Reproduce Fig. 2.8 (left) from  M. Buballa, Physics Reports 407 (2005) 205-376
    // (the figure uses parameters of Set II from the article, with G_V = 0)
    if (true)
    {
        printf("\tReproduce Fig. 2.8 (left) from  M. Buballa, Physics Reports\n");

        SetFilePath("tests/Buballa-Fig2.8-L/data/");

        SetParametersSet("BuballaR_2");
        
		int points_number = 1000;

        parameters.model.bare_mass = 0; // In the reference, the bare mass was
										// zero for this test

		double mass = 0;
        
        double chemical_potential[4] = {0.0, 300.0, 368.6, 400.0};

		double min_renormalized_chemical_potential = 0.0;
		double max_renormalized_chemical_potential = 1000;

		double min_mass = 0.0;
        double max_mass = 1000.0;

		double renorm_chem_pot_step = Step(min_renormalized_chemical_potential,
						   				   max_renormalized_chemical_potential,
						   				   points_number);

		double mass_step = Step(min_mass, max_mass, points_number);
        
        double vacuum_mass = VacuumMassDetermination();

        double vacuum_thermodynamic_potential = ThermodynamicPotential(vacuum_mass, 0.0, 0.0, 0.0);

        for (int i = 0; i < 4; i++){

            char filename_1[256];
            sprintf(filename_1, "ZeroedRenormalizedChemPotEquation_BR2L_%d.dat", i);

    		FILE * f = OpenFile(filename_1);

    		renorm_chem_pot_equation_input input;
    		input.chemical_potential = chemical_potential[i];
    		input.mass = mass;

			double mu = 0;
    		while (mu < points_number) {
        		fprintf(f,
           	     		"%20.15E\t%20.15E\n",
                		mu,
                		ZeroedRenormalizedChemicalPotentialEquation(mu, &input));
        		mu += renorm_chem_pot_step;
   	 		}

    		fclose(f);

            gsl_vector * mass_vector = gsl_vector_alloc(points_number);
            gsl_vector * output = gsl_vector_alloc(points_number);
            
            double m = 0;
            
            for (int j = 0; j < points_number; j++) {
                
                double renormalized_chemical_potential = chemical_potential[i];
                
                double fermi_momentum = 0;
                if (pow(renormalized_chemical_potential, 2.0) > pow(m, 2.0)){
                    fermi_momentum = sqrt(pow(renormalized_chemical_potential, 2.0)
                                          - pow(m, 2.0));
                }
                
                double thermodynamic_potential = ThermodynamicPotential(m,
                                                                        fermi_momentum,
                                                                        chemical_potential[i],
                                                                        renormalized_chemical_potential);
                gsl_vector_set(mass_vector, j, m);
                gsl_vector_set(output, j, thermodynamic_potential - vacuum_thermodynamic_potential);
                
                m += mass_step;
            }
            
            char filename[256];
            sprintf(filename, "Fig2.8L_BuballaR_%d.dat", i);
            
            WriteVectorsToFile(filename,
                               "# mass, thermodynamic potential\n",
                               2,
                               mass_vector,
                               output);
  
        }
        
        SetFilePath("tests/Buballa-Fig2.8-L/");
        FILE * log_file = OpenFile("run.log");

        fprintf(log_file,
                "The following tests were executed for %s parameterization:\n",
                parameters.parameters_set_identifier);
        fprintf(log_file,
                "\tCalculation of the hermodynamic potential as function of mass "
                "(Reproduce Fig. 2.8 (left) from  M. Buballa, Physics Reports 407 (2005) 205-376.\n"
                "\tFiles:tests/data/Fig2.8L_BuballaR_*.dat\n");

        PrintParametersToFile(log_file);
        
        fclose(log_file);

        SetFilePath(NULL);
    }
    
#pragma mark Reproduce Fig. 2.8 (right) from  M. Buballa, Physics Reports
    
    // Reproduce Fig. 2.8 (right) from  M. Buballa, Physics Reports 407 (2005) 205-376
    // (the figure uses parameters of Set II from the article, with G_V = G_S)
    if (true)
    {
        printf("\tReproduce Fig. 2.8 (right) from  M. Buballa, Physics Reports\n");
        SetFilePath("tests/Buballa-Fig2.8-R/data/");
        
        SetParametersSet("BuballaR_2_GV");
        
		int points_number = 1000;

        parameters.model.bare_mass = 0; // In the reference, the bare mass was
										// zero for this test
        
        double chemical_potential[4] = {0.0, 430.0, 440.0, 444.3};

        double mass[4] = {1.0, 100, 300, 700};

		double min_renorm_chemical_potential = 0.0;
		double max_renorm_chemical_potential = 1000.0;

		double step = Step(min_renorm_chemical_potential,
						   max_renorm_chemical_potential,
						   points_number);

        for (int i = 0; i < 4; i++){
            for (int j = 0; j < 4; j++){
                char filename_1[256];
                sprintf(filename_1, "ZeroedRenormalizedChemPotEquation_BR2R_%d_%d.dat", i, j);

    			FILE * f = OpenFile(filename_1);

    			renorm_chem_pot_equation_input input;
    			input.chemical_potential = chemical_potential[i];
    			input.mass = mass[j];

				double mu = 0;
    			while (mu < points_number) {
        			fprintf(f,
                			"%20.15E\t%20.15E\n",
                			mu,
                			ZeroedRenormalizedChemicalPotentialEquation(mu, &input));
        			mu += step;
    			}

    			fclose(f);
            }
        }
        
        double vacuum_mass = VacuumMassDetermination();
        
        double vacuum_thermodynamic_potential = ThermodynamicPotential(vacuum_mass, 0.0, 0.0, 0.0);
        
        for (int i = 0; i < 4; i++){
            
            double minimum_mass = 0.0;
            double maximum_mass = 1000.0;
            int points_number = 1000;
            
            double step = (maximum_mass - minimum_mass) / (points_number - 1);
            
            gsl_vector * mass_vector = gsl_vector_alloc(points_number);
            gsl_vector * output = gsl_vector_alloc(points_number);
            gsl_vector * renormalized_chemical_potential_vector = gsl_vector_alloc(points_number);
            
            // Prepare function to be passed to the root finding algorithm
            gsl_function F;
            renorm_chem_pot_equation_input input;
            F.function = &ZeroedRenormalizedChemicalPotentialEquation;
            F.params = &input;
     
            /*
             * Determine the renormalized chemical potential by root-finding
             * for each value of mass
             */
            
			RenormalizedChemicalPotentialIntegrationParameters params =
				parameters.renormalized_chemical_potential_integration;

            double m = 0;
            for (int j = 0; j < points_number; j++) {
                
                double renormalized_chemical_potential;

                // Prepare input for ZeroedRenormalizedChemicalPotentialEquation
                input.chemical_potential = chemical_potential[i];
                input.mass = m;
                
                // If the chemical potential is zero, the solution is zero.
                // Otherwise it needs to be calculated
                if (chemical_potential[i] == 0){
                    renormalized_chemical_potential = 0;
                }
                else{
                    int status = UnidimensionalRootFinder(&F,
                                                          params.lower_bound,
                                                          params.upper_bound,
                                                          params.abs_error,
                                                          params.rel_error,
                                                          params.max_iter,
                                                          &renormalized_chemical_potential);
                    if (status == -1)
                        renormalized_chemical_potential = 0;
                }
                
                gsl_vector_set(renormalized_chemical_potential_vector,
							   j,
							   renormalized_chemical_potential);
                
                double fermi_momentum = 0;
                if (pow(renormalized_chemical_potential, 2.0) > pow(m, 2.0)){
                    fermi_momentum = sqrt(pow(renormalized_chemical_potential, 2.0)
                                          - pow(m, 2.0));
                }
                
                double thermodynamic_potential = ThermodynamicPotential(m,
                                                                        fermi_momentum,
                                                                        chemical_potential[i],
                                                                        renormalized_chemical_potential);
                gsl_vector_set(mass_vector, j, m);
                gsl_vector_set(output, j, thermodynamic_potential - vacuum_thermodynamic_potential);
                
                m += step;
            }
            
            char filename[256];
            sprintf(filename, "Fig2.8R_BuballaR_%d.dat", i);
            
            WriteVectorsToFile(filename,
                               "# mass, thermodynamic potential\n",
                               2,
                               mass_vector,
                               output);
            
            sprintf(filename, "renormalized_chemical_potential_%d.dat", i);
            WriteVectorsToFile(filename,
                               "#mass, renormalized_chemical_potential\n",
                               2,
                               mass_vector,
                               renormalized_chemical_potential_vector);
            
            gsl_vector_free(output);
            gsl_vector_free(mass_vector);
            gsl_vector_free(renormalized_chemical_potential_vector);
 
        }

        SetFilePath("tests/Buballa-Fig2.8-R/");
        FILE * log_file = OpenFile("run.log");

        fprintf(log_file,
                "The following tests were executed for %s parameterization:\n",
                parameters.parameters_set_identifier);
        fprintf(log_file,
                "\tCalculation of the thermodynamic potential as function of mass "
                "(Reproduce Fig. 2.8 (right) from  M. Buballa, Physics Reports 407 (2005) 205-376.\n"
                "\tFiles:tests/data/Fig2.8R_BuballaR_*.dat\n");
        fprintf(log_file,
                "\tZeroed renormalized chemical potential equation for selected parameters"
				" (as function of renormalized chemical potential)\n");
        fprintf(log_file,
                "\tRenormalized chemical potential (as function of mass)\n");
        fprintf(log_file,
                "\tVacuum mass: %f\n", vacuum_mass);
        fprintf(log_file,
                "\tVacuum thermodynamic potential: %f\n", vacuum_thermodynamic_potential);
        
        PrintParametersToFile(log_file);
        
        fclose(log_file);

        SetFilePath(NULL);
    }
    
#pragma mark Fermi-Dirac Distributions
    
    // Prints Fermi-Dirac distributions for selected values of temperature
    // and chemical potential as function of momentum
    if (true)
    {
        printf("\tFermi-Dirac Distributions\n");
        SetFilePath("tests/Fermi-Dirac-distributions/data/");
        
        int n_pts = 1000;
        
        double min_momentum = 0.0;
        double max_momentum = 400.0;
        double step = (max_momentum - min_momentum) / (n_pts - 1);
        
        double temperature[4] = {5, 10.0, 20.0, 30.0};
        double chemical_potential[4] = {50.0, 100.0, 200.0, 300.0};
        double mass[4] = {50.0, 100.0, 150.0, 200.0};
        
        gsl_vector * momentum_vector = gsl_vector_alloc(n_pts);
        gsl_vector * fp_vector = gsl_vector_alloc(n_pts);
        gsl_vector * fa_vector = gsl_vector_alloc(n_pts);
        
        for (int i = 0; i < 4; i++){ // temperature
            for (int j = 0; j < 4; j++){ // chemical potential
                for (int k = 0; k < 4; k++){ // mass
                    
                    double momentum = min_momentum;
                    
                    for (int l = 0; l < n_pts; l++){

                        double energy = sqrt(pow(momentum, 2.0) + pow(mass[k], 2.0));
                        
                        double fp = FermiDiracDistributionForParticles(energy,
																	   chemical_potential[j],
																	   temperature[i]);

                        double fa = FermiDiracDistributionForAntiparticles(energy,
																		   chemical_potential[j],
																		   temperature[i]);
                        
                        gsl_vector_set(momentum_vector, l, momentum);
                        gsl_vector_set(fp_vector, l, fp);
                        gsl_vector_set(fa_vector, l, fa);
                        
                        momentum += step;
                    }

                    char filename[256];
                    sprintf(filename, "FD_%d_%d_%d.dat", i, j, k);
                    
                    WriteVectorsToFile(filename,
                                       "# momentum, Fermi-Dirac distribution for particles, = for antiparticles\n",
                                       3,
                                       momentum_vector,
                                       fp_vector,
                                       fa_vector);
                }
            }
        }
        
        gsl_vector_free(momentum_vector);
        gsl_vector_free(fp_vector);
        gsl_vector_free(fa_vector);
        
        SetFilePath("tests/Fermi-Dirac-distributions/");
        FILE * log_file = OpenFile("run.log");
        
        fprintf(log_file,
                "Prints Fermi-Dirac distributions for selected values of temperature\n"
                "and chemical potential as function of momentum\n");
        
        PrintParametersToFile(log_file);

        fclose(log_file);
        
        SetFilePath(NULL);
    }
    
#pragma mark Fermi-Dirac Distribution Integrals
    
    // Tests integration of Fermi-Dirac distributions
    if (true)
    {
        printf("\tFermi-Dirac Distribution Integrals\n");
        SetFilePath("tests/Fermi-Dirac-distrib-integrals/data/");
        
        SetParametersSet("BuballaR_2");
        
        int num_points = 1000;
        
        double min_mass = 0.01;
        double max_mass = 1000;
        double step = (max_mass - min_mass) / ((double)(num_points - 1));
        
        double renormalized_chemical_potential[4] = {100.0, 200.0, 400.0, 600.0};
        double temperature[4] = {5.0, 10.0, 15.0, 20.0};

        gsl_vector * mass_vector = gsl_vector_alloc(num_points);
        gsl_vector * fermi_dirac_int_1 = gsl_vector_alloc(num_points);
        gsl_vector * fermi_dirac_int_2 = gsl_vector_alloc(num_points);
        
        for (int i = 0; i < 4; i++){
            
            parameters.finite_temperature.temperature = temperature[i];

            for (int j = 0; j < 4; j++){
                
                double m = min_mass;
                
                for (int k = 0; k < num_points; k++){
                    
                    double int_1 =
						FermiDiracDistributionFromDensityIntegral(m,
																  renormalized_chemical_potential[j]);

                    double int_2 =
						FermiDiracDistributionIntegralFromGapEquation(m,
																	  renormalized_chemical_potential[j]);
                
                    gsl_vector_set(mass_vector, k, m);
                    gsl_vector_set(fermi_dirac_int_1, k, int_1);
                    gsl_vector_set(fermi_dirac_int_2, k, int_2);
                    
                    m += step;
                    
                }
                
                char filename[256];
                sprintf(filename,
                        "fermi_dirac_distribution_from_density_integral_%d_%d.dat",
                        i,
                        j);
                
                WriteVectorsToFile(filename,
                                   "# mass, integral of fermi dirac dist from density\n",
                                   2,
                                   mass_vector,
                                   fermi_dirac_int_1);
                
                sprintf(filename,
                        "fermi_dirac_distribution_from_gap_eq_integral_%d_%d.dat",
                        i,
                        j);

                WriteVectorsToFile(filename,
                                   "# mass, integral of fermi dirac dist from gap eq\n",
                                   2,
                                   mass_vector,
                                   fermi_dirac_int_2);
            }
        }

        gsl_vector_free(mass_vector);
        gsl_vector_free(fermi_dirac_int_1);
        gsl_vector_free(fermi_dirac_int_2);
        
        SetFilePath("tests/Fermi-Dirac-distrib-integrals/");

        FILE * log_file = OpenFile("run.log");
        fprintf(log_file,
                "The following tests were executed for %s parameterization:\n",
                parameters.parameters_set_identifier);
        fprintf(log_file,
                "\tCalculation of integrals of fermi distributions as function of mass.\n");
        
        PrintParametersToFile(log_file);
        
        fclose(log_file);

        SetFilePath(NULL);
    }
    
#pragma mark Mass Gap Zeroed Equation for Selected Temperatures
    
    // writes gap equation as function of mass for selected temperatures
    //    What exactly is that? I don't remember ...
    //
    if (true)
	{
        printf("\tMass Gap Zeroed Equation for Selected Temperatures\n");
        SetFilePath("tests/zeroed-gap-equation/data/");
        
	  	SetParametersSet("BuballaR_2");

	  	int n_pts = 1000;

	  	double min_mass = 0.0;
	  	double max_mass = 1000.0;
	  	double step = (max_mass - min_mass) / (n_pts - 1);

	  	double temperature[4] = {5.0, 10.0, 15.0, 20.0};
	  	double renormalized_chemical_potential[4] = {100.0, 200.0, 400.0, 600.0};

	  	gsl_vector * m_vector = gsl_vector_alloc(n_pts);
	  	gsl_vector * zeroed_gap_vector = gsl_vector_alloc(n_pts);


	  	for (int i = 0; i < 4; i++){

		  	parameters.finite_temperature.temperature = temperature[i];

			for (int j = 0; j < 4; j++){

                double m = min_mass;

				for (int k = 0; k < n_pts; k++){

			  		double integ =
						FermiDiracDistributionIntegralFromGapEquation(m,
																	  renormalized_chemical_potential[j]);

			 		gsl_vector_set(zeroed_gap_vector,
								   k,
								   m - parameters.model.bare_mass - integ);

				  	gsl_vector_set(m_vector, k, m);

				  	m += step;
				}

				char filename[256];
			  	sprintf(filename, "zeroed_gap_eq_%d_%d.dat", i,	j);

				WriteVectorsToFile(filename,
								   "# mass, zeroed gap equation\n",
								   2,
								   m_vector,
								   zeroed_gap_vector);
			}
	  	}

	  	gsl_vector_free(m_vector);
	  	gsl_vector_free(zeroed_gap_vector);

        SetFilePath("tests/zeroed-gap-equation/");
        FILE * log_file = OpenFile("run.log");

		fprintf(log_file,
                "The following tests were executed for %s parameterization:\n",
                parameters.parameters_set_identifier);
        fprintf(log_file,
                "\tCalculation of zeroed gap eq for T != 0 as function of mass.\n");
        
        PrintParametersToFile(log_file);

        fclose(log_file);

        SetFilePath(NULL);
	}
    
#pragma mark Maps of Mass and Renormalized Chemical Potential Zeroed Equations
    
    // Calculates zeroed gap and barionic densities equations so we can see both
    // and have an insight of what's going on
    if (true)
    {
        printf("\tMaps of Mass and Renormalized Chemical Potential Zeroed Equations\n");
        SetFilePath("tests/maps/data/");
        
        SetParametersSet("BuballaR_2");

        const int num_densities = 10;
        const int num_temperatures = 10;

        const double barionic_density[10] = {0.04, 0.08, 0.12, 0.16, 0.2, 0.24, 0.28, 0.32, 0.4, 0.44};
        const double temperature[10] = {1.0, 3.0, 7.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40.0, 50.0};

        int mass_n_pts = 150;
        int renorm_chem_pot_n_pts = 150;
        double min_mass = 0.0;
        double max_mass = 600.0;
        double min_renormalized_chemical_potential = 0.0;
        double max_renormalized_chemical_potential = 600.0;

        double tolerance_dens = 0.05;
        double tolerance_gap = 0.5;

        gsl_vector * map_gap_x = gsl_vector_alloc(mass_n_pts * renorm_chem_pot_n_pts);
        gsl_vector * map_gap_y = gsl_vector_alloc(mass_n_pts * renorm_chem_pot_n_pts);
        int map_gap_num_points;

        gsl_vector * map_dens_x = gsl_vector_alloc(mass_n_pts * renorm_chem_pot_n_pts);
        gsl_vector * map_dens_y = gsl_vector_alloc(mass_n_pts * renorm_chem_pot_n_pts);
        int map_dens_num_points;

        for (int i = 0; i < num_temperatures; i++){ // Temperature

            parameters.finite_temperature.temperature = temperature[i];

            for (int j = 0; j < num_densities; j++){

                MapFunction(&ZeroedGapEquationForFiniteTemperature,
                            min_mass,
                            max_mass,
                            mass_n_pts,
                            min_renormalized_chemical_potential,
                            max_renormalized_chemical_potential,
                            renorm_chem_pot_n_pts,
                            tolerance_gap,
                            NULL,
                            false,
                            map_gap_x,
                            map_gap_y,
                            &map_gap_num_points);

                MapFunction(&ZeroedBarionicDensityEquationForFiniteTemperature,
                            min_mass,
                            max_mass,
                            mass_n_pts,
                            min_renormalized_chemical_potential,
                            max_renormalized_chemical_potential,
                            renorm_chem_pot_n_pts,
                            tolerance_dens,
                            (void *)&(barionic_density[j]),
                            false,
                            map_dens_x,
                            map_dens_y,
                            &map_dens_num_points);

                double x_intersection;
                double y_intersection;

                IntersectionPointOfTwoMaps(map_gap_x,
                                           map_gap_y,
                                           map_gap_num_points,
                                           map_dens_x,
                                           map_dens_y,
                                           map_dens_num_points,
                                           &x_intersection,
                                           &y_intersection);

                char filename[256];
                sprintf(filename, "map_gap_%d_%d.dat", i, j);
                WriteVectorsToFileUpToIndex(filename,
                                            "# Map of the region of zeroed gap equation that is near zero\n"
                                            "# mass, renormalized chemical potential\n",
                                            map_gap_num_points,
                                            2,
                                            map_gap_x,
                                            map_gap_y);

                sprintf(filename, "map_dens_%d_%d.dat", i, j);
                WriteVectorsToFileUpToIndex(filename,
                                            "# Map of the region of zeroed density gap equation that is near zero\n"
                                            "# mass, renormalized chemical potential\n",
                                            map_dens_num_points,
                                            2,
                                            map_dens_x,
                                            map_dens_y);

                sprintf(filename, "intersection_%d_%d.dat", i, j);
                FILE * file = OpenFile(filename);
                fprintf(file, "%20.15E\t%20.15E\n", x_intersection, y_intersection);
                fclose(file);

            }

        }

        gsl_vector_free(map_gap_x);
        gsl_vector_free(map_gap_y);
        gsl_vector_free(map_dens_x);
        gsl_vector_free(map_dens_y);

        SetFilePath("tests/maps/");
        FILE * log_file = OpenFile("run.log");
        
        fprintf(log_file,
                "Calculates zeroed gap and barionic densities equations so we can see both\n"
                "and have an insight of what's going on.\n");
        PrintParametersToFile(log_file);

        fclose(log_file);

        SetFilePath(NULL);
    }

#pragma mark Mass and Renormalized Chemical Potential for Finite Temperature

    // Prints mass and renormalized chemical potential calculation as function
    // of barionic density
    if (true)
    {
        printf("\tMass and Renormalized Chemical Potential for Finite Temperature\n");
        SetFilePath("tests/mass-renorm-chem-pot/data/");

        SetParametersSet("BuballaR_2");

        int n_pts = 100;

        double min_barionic_density = 0.1;
        double max_barionic_denstiy = 0.3;
        double step = (max_barionic_denstiy - min_barionic_density) / ((double)(n_pts - 1));

        double temperature[4] = {10.0, 15.0, 20.0, 25.0};

        gsl_vector * dens_vector = gsl_vector_alloc(n_pts);
        gsl_vector * mass_vector = gsl_vector_alloc(n_pts);
        gsl_vector * renormalized_chemical_potential_vector = gsl_vector_alloc(n_pts);

        for (int i = 0; i < 4; i++){

            double dens = min_barionic_density;
            parameters.finite_temperature.temperature = temperature[i];

            double mass;
            double renormalized_chemical_potential;

            for (int j = 0; j < n_pts; j++){

                SolveMultiRoots(dens,
                               &mass,
                               &renormalized_chemical_potential);

                gsl_vector_set(dens_vector, j, dens);
                gsl_vector_set(mass_vector, j, mass);
                gsl_vector_set(renormalized_chemical_potential_vector, j, renormalized_chemical_potential);

                dens += step;

            }

            char filename[256];
            sprintf(filename, "mass_and_renorm_chem_pot_%d.dat", i);

            WriteVectorsToFile(filename,
                               "# barionic density, mass, renormalized chemical potential\n",
                               3,
                               dens_vector,
                               mass_vector,
                               renormalized_chemical_potential_vector);
        }

        gsl_vector_free(dens_vector);
        gsl_vector_free(mass_vector);
        gsl_vector_free(renormalized_chemical_potential_vector);

        SetFilePath("tests/mass-renorm-chem-pot/");
        FILE * log_file = OpenFile("run.log");
        fprintf(log_file,
                "The following tests were executed for %s parameterization:\n",
                parameters.parameters_set_identifier);
        fprintf(log_file,
                "\tCalculation of mass and renormalized chemical potential as function of barionic density.\n");
        
        PrintParametersToFile(log_file);

        fclose(log_file);

        SetFilePath(NULL);
    }
    
#pragma mark Entropy calculation methods (transient)
    if (true)
    {
        printf("\tEntropy calculation methods\n");
        SetFilePath("tests/transient/data/");

        SetParametersSet("BuballaR_2");

        double mass[6] = {50.0, 100.0, 200.0, 300.0, 400.0, 500.0};
        double renormalized_chemical_potential[6] = {50.0, 100.0, 200.0, 300.0, 400.0, 500.0};
        double temperature[6] = {1.0, 5.0, 7.0, 10.0, 20.0, 35.0};

        int n_pts = 1000;
        double min_momentum = 0.0;
        double max_momentum = parameters.model.cutoff;
        double mom_step = (max_momentum - min_momentum) / (double)(n_pts - 1);

        // FIXME: Remove other methods of calculation once I'm sure the one adopted works fine
        gsl_vector * momentum_vector = gsl_vector_alloc(n_pts);
        gsl_vector * entropy_integrand_vector = gsl_vector_alloc(n_pts);
        gsl_vector * entropy_integrand_vector_deriv = gsl_vector_alloc(n_pts);
        gsl_vector * entropy_integrand_vector_art = gsl_vector_alloc(n_pts);

        for (int i = 0; i < 6; i++){
            for (int j = 0; j < 6; j++){
                for (int k = 0; k < 6; k++){
                    entropy_integrand_parameters par;
                    par.mass = mass[i];
                    par.renormalized_chemical_potential = renormalized_chemical_potential[j];
                    par.temperature = temperature[k];

                    double p = 0;
                    for (int l = 0; l < n_pts; l++){

                        double entropy_integrand = EntropyIntegrand(p, &par);
                        double entropy_integrand_deriv = EntropyIntegrandFromDerivative(p, &par);
                        double entropy_integrand_art = EntropyIntegrandArt(p, &par);

                        gsl_vector_set(momentum_vector, l, p);
                        gsl_vector_set(entropy_integrand_vector, l, entropy_integrand);
                        gsl_vector_set(entropy_integrand_vector_deriv, l, entropy_integrand_deriv);
                        gsl_vector_set(entropy_integrand_vector_art, l, entropy_integrand_art);

                        p += mom_step;
                    }

                    char filename[256];
                    sprintf(filename, "entropy_integrand_%d_%d_%d.dat", i, j, k);
                    
                    WriteVectorsToFile(filename,
                                       "# momentum, entropy integrand\n",
                                       2,
                                       momentum_vector,
                                       entropy_integrand_vector);

                    sprintf(filename, "entropy_integrand_deriv_%d_%d_%d.dat", i, j, k);

                    WriteVectorsToFile(filename,
                                       "# momentum, entropy integrand\n",
                                       2,
                                       momentum_vector,
                                       entropy_integrand_vector_deriv);

                    sprintf(filename, "entropy_integrand_art_%d_%d_%d.dat", i, j, k);

                    WriteVectorsToFile(filename,
                                       "# momentum, entropy integrand\n",
                                       2,
                                       momentum_vector,
                                       entropy_integrand_vector_art);

                }
            }
        }

        gsl_vector_free(momentum_vector);
        gsl_vector_free(entropy_integrand_vector);
        gsl_vector_free(entropy_integrand_vector_deriv);
        gsl_vector_free(entropy_integrand_vector_art);

        SetFilePath("tests/transient/");
        FILE * log_file = OpenFile("run.log");

        fprintf(log_file, "Verifies the best routine to calculate entropy.\n");
        fprintf(log_file,
                "mass = {50.0, 100.0, 200.0, 300.0, 400.0, 500.0};\n"
                "renormalized chemical potential = {50.0, 100.0, 200.0, 300.0, 400.0, 500.0};\n"
                "temperature = {1.0, 5.0, 7.0, 10.0, 20.0, 35.0};\n");
        PrintParametersToFile(log_file);

        fclose(log_file);

        SetFilePath(NULL);
    }

#pragma mark Entropy
    // The entropy only depends on the kinectic term, so it does
    // have a 'closed' form. Here we use it to calculate the entropy
    // for a few parameters values just to see if we get a well
    // behaved solution.
    if (true)
    {
        printf("\tEntropy\n");
        SetFilePath("tests/entropy/data/");

        SetParametersSet("BuballaR_2");

        int n_pts = 1000;

        double temperature[4] = {1.0, 5.0, 10.0, 15.0};
        double renormalized_chemical_potential[4] = {50.0, 100.0, 200.0, 350.0};

        double mass_min = 0.0;
        double mass_max = 400.0;
        double mass_step = (mass_max - mass_min) / (double)(n_pts - 1);

        gsl_vector * mass_vector = gsl_vector_alloc(n_pts);
        gsl_vector * entropy_vector = gsl_vector_alloc(n_pts);

        for (int i = 0; i < 4; i++){
            for (int j = 0; j < 4; j++){

                double mass = mass_min;
                for (int k = 0; k < n_pts; k++){
                    double entropy = Entropy(mass, temperature[i], renormalized_chemical_potential[j]);

                    gsl_vector_set(mass_vector, k, mass);
                    gsl_vector_set(entropy_vector, k, entropy);

                    mass += mass_step;
                }

                char filename[256];
                sprintf(filename, "entropy_%d_%d.dat", i, j);

                WriteVectorsToFile(filename,
                                   "# mass, entropy\n",
                                   2,
                                   mass_vector,
                                   entropy_vector);
            }
        }

        gsl_vector_free(mass_vector);
        gsl_vector_free(entropy_vector);

        SetFilePath("tests/entropy/");
        FILE * log_file = OpenFile("run.log");

        fprintf(log_file,
                "The entropy only depends on the kinectic term, so it does\n"
                "have a 'closed' form. Here we use it to calculate the entropy\n"
                "for a few parameters values just to see if we get a well\n"
                "behaved solution.\n");

        PrintParametersToFile(log_file);

        fclose(log_file);

        SetFilePath(NULL);
    }

#pragma mark Reproduce Fig. 2.7 from Buballa Physics Reports
    if (true)
    {
        printf("\tReproduce Fig. 2.7 from Buballa Physics Reports\n");
        SetFilePath("tests/Buballa-Fig2.7/data/");

        SetParametersSet("BuballaR_2");

        int n_pts = 1000;
        double temperature_min = 0.0;
        double temperature_max = 300.0;
        double temperature_step = (temperature_max - temperature_min) / (double)(n_pts - 1);

        gsl_vector * temperature_vector = gsl_vector_alloc(n_pts);
        gsl_vector * mass_vector = gsl_vector_alloc(n_pts);

        double temperature = temperature_min;
        for (int i = 0; i < n_pts; i++){

            parameters.finite_temperature.temperature = temperature;

            // Prepare function to be passed to the root finding algorithm
            gsl_function F;
            F.function = &ZeroedGapEquationForFiniteTemperatureTest;

            double mass;
            int status = UnidimensionalRootFinder(&F,
                                                  0.0,
                                                  500.0,
                                                  1.0E-7,
                                                  1.0E-7,
                                                  1000,
                                                  &mass);
            if (status == -1)
                mass = 0;

            gsl_vector_set(temperature_vector, i, temperature);
            gsl_vector_set(mass_vector, i, mass);

            temperature += temperature_step;
        }

        WriteVectorsToFile("mass_temperature.dat",
                           "# Reproduce Fig. 2.7 from Buballa, Physics Reports bare_mass not zero\n"
                           "# temperature, mass\n",
                           2,
                           temperature_vector,
                           mass_vector);

        // Repeat for bare_mass = 0
        parameters.model.bare_mass = 0;

        temperature = temperature_min;
        for (int i = 0; i < n_pts; i++){

            // FIXME: change the program to allow temperature as a variable
            // instead of as a parameter
            parameters.finite_temperature.temperature = temperature;

            // Prepare function to be passed to the root finding algorithm
            gsl_function F;
            F.function = &ZeroedGapEquationForFiniteTemperatureTest;

            // This case will not have solutions beyond T = 220 MeV
            double mass = 0;

            if (temperature < 220.0){
                int status = UnidimensionalRootFinder(&F,
                                                      0.1,
                                                      500.0,
                                                      1.0E-7,
                                                      1.0E-7,
                                                      6000,
                                                      &mass);
                if (status == -1)
                    mass = 0;
            }

            gsl_vector_set(temperature_vector, i, temperature);
            gsl_vector_set(mass_vector, i, mass);

            temperature += temperature_step;
        }

        WriteVectorsToFile("mass_temperature_bare_mass_zero.dat",
                           "# Reproduce Fig. 2.7 from Buballa, Physics Reports bare_mass = 0\n"
                           "# temperature, mass\n",
                           2,
                           temperature_vector,
                           mass_vector);

        gsl_vector_free(temperature_vector);
        gsl_vector_free(mass_vector);

        SetFilePath("tests/Buballa-Fig2.7/");
        FILE * log_file = OpenFile("run.log");

        fprintf(log_file, "Reproduce Fig. 2.7 from Buballa Physics Reports\n");

        PrintParametersToFile(log_file);

        fclose(log_file);

        SetFilePath(NULL);
    }

#pragma mark Test root finding for renormalized chemical potential
    // After we reach the zero mass case, we use a onedimensional root finding
    // to determine the renormalized chemical potential. However, for some
    // reason the results seems to reach a maximum value. After this maximum,
    // the root finding will fail. One possibility is that we reach a maximum
    // value for the integral.
    if (true)
    {
        printf("\tTest root finding for renormalized chemical potential\n");
        SetFilePath("tests/renorm-chem-pot-transient/data/");

        SetParametersSet("Buballa_1");

        int num_pts = 1000;

        double mass = 0;
        double barionic_density[12] = {0.1, 0.5, 0.7, 1.0, 1.4, 2.0, 2.1, 2.2, 2.3, 2.35, 2.4, 2.5};

        // Range of chemical potential which will be tested
        double renorm_chem_pot_min = 0.0;
        double renorm_chem_pot_max = 3000;
        double step = (renorm_chem_pot_max - renorm_chem_pot_min) / (double)(num_pts - 1);

        gsl_vector * renorm_chem_pot_vector = gsl_vector_alloc(num_pts);
        gsl_vector * zeroed_dens_eq_vector = gsl_vector_alloc(num_pts);

        for (int i = 0; i < 12; i++){

            double mu_r = renorm_chem_pot_min;

            for (int j = 0; j < num_pts; j++){
                gsl_vector_set(renorm_chem_pot_vector, j, mu_r);

                double zeroed_dens_eq = ZeroedBarionicDensityEquationForFiniteTemperature(mass,
                                                                                          mu_r,
                                                                                          &(barionic_density[i]));
                gsl_vector_set(zeroed_dens_eq_vector, j, zeroed_dens_eq);

                mu_r += step;
            }

            char filename[256];
            sprintf(filename, "zeroed_dens_eq_bar_dens_%d.dat", i);
            
            WriteVectorsToFile(filename,
                               "# renormalized chemical potential, zeroed density equation \n",
                               2,
                               renorm_chem_pot_vector,
                               zeroed_dens_eq_vector);
        }
        
        SetFilePath(NULL);
    }
}
Пример #16
0
//Find existing ocean regions and place costal regions beside them.
void TerraformCoast ()
{

  int             x, y;
  Region          r;
  int             pass;
  unsigned        i;
  unsigned        cliff_grid;
  bool            is_coast;
  bool            is_cliff;
  vector<GLcoord> queue;
  GLcoord         current;

  cliff_grid = WORLD_GRID / 8;
  //now define the coast 
  for (pass = 0; pass < 2; pass++) {
    queue.clear ();
    for (x = 0; x < WORLD_GRID; x++) {
      for (y = 0; y < WORLD_GRID; y++) {
        r = WorldRegionGet (x, y);
        //Skip already assigned places
        if (r.climate != CLIMATE_INVALID)
          continue;
        is_coast = false;
        //On the first pass, we add beach adjoining the sea
        if (!pass && is_climate_present (x, y, 1, CLIMATE_OCEAN)) 
          is_coast = true;
        //One the second pass, we add beach adjoining the beach we added on the previous step
        if (pass && is_climate_present (x, y, 1, CLIMATE_COAST)) 
          is_coast = true;
        if (is_coast) {
          current.x = x;
          current.y = y;
          queue.push_back (current);
        }
      }
    }
    //Now we're done scanning the map.  Run through our list and make the new regions.
    for (i = 0; i < queue.size (); i++) {
      current = queue[i];
      r = WorldRegionGet (current.x, current.y);
      is_cliff = (((current.x / cliff_grid) + (current.y / cliff_grid)) % 2) != 0;
      if (!pass) 
        sprintf (r.title, "%s beach", get_direction_name (current.x, current.y));
      else
        sprintf (r.title, "%s coast", get_direction_name (current.x, current.y));
      //beaches are low and partially submerged
      r.geo_detail = 5.0f + Entropy (current.x, current.y) * 10.0f;
      if (!pass) {
        r.geo_bias = -r.geo_detail * 0.5f;
        if (is_cliff)
          r.flags_shape |= REGION_FLAG_BEACH_CLIFF;
        else
          r.flags_shape |= REGION_FLAG_BEACH;
      } else 
        r.geo_bias = 0.0f;
      r.cliff_threshold = r.geo_detail * 0.25f;
      r.moisture = 1.0f;
      r.geo_water = 0.0f;
      r.flags_shape |= REGION_FLAG_NOBLEND;
      r.climate = CLIMATE_COAST;
      WorldRegionSet (current.x, current.y, r);
    }
  }


}
Пример #17
0
// Calculate the binary entropy.
void SeedSelector::CalculateEntropy() {
    for (size_t i = 0; i < _barcode_length; ++i) {
        _entropy[i] = Entropy(_position_weight_matrix[i]);
    }
}