Commit d4774ba2 authored by Ruben Farinelli's avatar Ruben Farinelli
Browse files

Allowed the possibility to define the number of angle-dependent results for the MC simulations

parent c21f5f3a
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ MC_HYDRO = ${MC_INSTDIR}/../../gr_code/hydrodynamics
MC_SYNC                 = ${MC_INSTDIR}/../../gr_code/synchrotron




#========================================================================


@@ -37,15 +39,22 @@ MC_SYNC_OBJ=${MC_SYNC}/envelop_gaussian.o ${MC_SYNC}/optimize_envelop.o ${MC_SYN
MC_SLAB_OBJ=${MC_SLAB}/electricfield_fromfile.o ${MC_SLAB}/read_resultsfile.o  ${MC_SLAB}/setup_gsl_objects.o ${MC_SLAB}/compute_cumulative_angdist.o 




all:  start_iteration

%.o: %.c $(DEPS)
	$(CC) -c  -o  $@ $< $(CFLAGS)

start_iteration:  ${LOCAL_DIR_OBJ} ${MC_GENERAL_OBJ} ${MC_POLARIZATION_OBJ} ${MC_ELE_DISTRIBUTION_OBJ} ${MC_COORD_OBJ} ${MC_SEED_OBJ}   ${MC_HYDRO_OBJ} ${MC_SLAB_OBJ} ${MC_SYNC_OBJ}

ifndef MC_INSTDIR
	$(error The enviroment variable MC_INSTDIR is not defined)
endif
	${CC} $^ -o $@ ${LDFLAGS}



clean:
	rm -f main_program.o ${LOCAL_DIR_OBJ} ${MC_GENERAL_OBJ} ${MC_POLARIZATION_OBJ} ${MC_ELE_DISTRIBUTION_OBJ} ${MC_COORD_OBJ} ${MC_SEED_OBJ}   ${MC_HYDRO_OBJ} ${MC_SLAB_OBJ} ${MC_SYNC_OBJ}	

+24 −9
Original line number Diff line number Diff line
#include "variables.h"
#include "globals.h"
#include "iteration_functions.h"
#include <mpi.h>
#include <stdio.h>


char* set_filename(char* root, char* tau_char, char* seed_char, char* albedo, char* method);
char* set_mc_filename(const char* root, double ktbb, double kte, double tau, int seed, double albedo,
                   const char* method);
@@ -11,6 +12,7 @@ void smart_double_to_string(char* buffer, size_t size, double value);
void int_to_string(char* buffer, size_t size, int value);



int seed;
double tau_c;
double albedobase;
@@ -18,8 +20,7 @@ double albedobase;
char* polarization_file;
char* diffusion_file;

// int nph;
// int rank;


int kiter;
int DiskPolarizationFlag;
@@ -72,7 +73,7 @@ int main(int argc, char* argv[])

    printf("Parameters for MC simulation\n");
    printf("method=mc\n");
    printf("nph=N       : number of simulated photons\n");
    printf("nphtot=N       : number of simulated photons\n");
    printf("kte=value   : electron temperature (default is 1 keV)\n");
    printf("For seed photons at the bottom of the slab select if they are unpolarized\n");
    printf(
@@ -111,9 +112,9 @@ int main(int argc, char* argv[])
      method = stringpar(argv[t]);
    }

    if (strstr(argv[t], "nph=") != NULL)
    if (strstr(argv[t], "nphtot=") != NULL)
    {
      nph = (int)numpar(argv[t]);
      nphtot = (int)numpar(argv[t]);
    }

    if (strstr(argv[t], "polarfile=") != NULL)
@@ -172,8 +173,16 @@ int main(int argc, char* argv[])
      albedo_char = stringpar(argv[t]);
      Albedoflag = 1;
    }
    
     if (strstr(argv[t], "nstepangles=") != NULL)
     {
      nstepangles = (int)numpar(argv[t]);
     }
    
  }
  
  

  /*=========================================================*/
  /*Default values*/
  /*=========================================================*/
@@ -204,6 +213,12 @@ int main(int argc, char* argv[])
    emax = 50.;
  }

  if (!nstepangles)
  {
    nstepangles = 10;
  }

	
  /*=========================================================*/

  if (!disktau || disktau == 0)
@@ -272,9 +287,9 @@ int main(int argc, char* argv[])
      exit(1);
    }

    if (nph == 0)
    if (nphtot == 0)
    {
      printf("Please select the number of photons for MC simulation with parametere nph=nph\n");
      printf("Please select the number of photons for MC simulation with parametere nphtot=nphtot\n");
      exit(1);
    }

@@ -318,7 +333,7 @@ int main(int argc, char* argv[])
      polarfile = set_mc_filename("energypolar_mc", ktbb, kte, disktau, seed, albedobase, "mc");
    }

    status = slab_mc(nph, seed);
    status = slab_mc(nphtot, seed);
  }

  else
+11 −15
Original line number Diff line number Diff line
#include "globals.h"
#include "iteration_functions.h"

#define NSC_MAX 1000
@@ -89,7 +90,6 @@ int slab_mc(int nphot, int seed)
  T_maxw = gsl_root_fsolver_bisection;
  s_maxw = gsl_root_fsolver_alloc(T_maxw);

  nstepangles = 20;
  obsmindeg = 0.;
  obsmaxdeg = 90.;

@@ -185,7 +185,8 @@ int slab_mc(int nphot, int seed)
      cos_theta = 2 * clock_random() - 1;
    }
    else if (seed == 2)
    {if (!emin)
    {
      if (!emin)
      {
        emin = 0.1;
      }
@@ -355,14 +356,11 @@ int slab_mc(int nphot, int seed)
    MPI_Reduce(struct_stokes[ii].counter, struct_stokes_average[ii].counter, nstepangles, MPI_INT,
               MPI_SUM, 0, MPI_COMM_WORLD);

     MPI_Reduce(struct_stokes[ii].array_Qsq, struct_stokes_average[ii].array_Qsq, nstepangles, MPI_DOUBLE,
               MPI_SUM, 0, MPI_COMM_WORLD);

	 MPI_Reduce(struct_stokes[ii].array_Usq, struct_stokes_average[ii].array_Usq, nstepangles, MPI_DOUBLE,
               MPI_SUM, 0, MPI_COMM_WORLD);


    MPI_Reduce(struct_stokes[ii].array_Qsq, struct_stokes_average[ii].array_Qsq, nstepangles,
               MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);

    MPI_Reduce(struct_stokes[ii].array_Usq, struct_stokes_average[ii].array_Usq, nstepangles,
               MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
  }

  for (ii = 0; ii < NSTEP_ENE; ii++)
@@ -422,8 +420,6 @@ int slab_mc(int nphot, int seed)
    collect_photons(0, k_lab, array_ene, reduce_array_counts, 1);
  }

  

  if (s_phi != NULL)
    gsl_root_fsolver_free(s_phi);
  if (s_disk != NULL)

results/colors.dat

0 → 100644
+11 −0
Original line number Diff line number Diff line
set terminal postscript eps color colortext
set output 'colors.eps'

set yrange [0:3]

a(x)=1
b(x)=1.2
c(x)=1.4
d(x)=1.6

plot a(x) lw 2 lc 0, b(x) lw 2 lc 1, c(x) lw 2 lc 2, d(x) lw 2 lc 3 
 No newline at end of file

results/colors.eps

0 → 100644
+1160 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading