Example #1
0
int main(int argc, char **argv) {
    int maxfd;
    fd_set fds;
    struct vty_cmd_table t;
    log_init();
    log_setlevel(LOGLVL_DEBUG);

    signal(SIGINT, shutdown);

    t.n = 1;
    t.table = &echo;


    vty_init(&t, atoi(argv[1]));
    while (1) {
        FD_ZERO(&fds);
        maxfd = vty_add_fds(&fds);

        select(maxfd+1, &fds, NULL, NULL, NULL);

        vty_process(&fds);
    }
    info("Done, exiting\n");

}
Example #2
0
int config_parse(const char *file, struct config *c) {
  char *buf, real_buf[BUF_LEN], arg[BUF_LEN];
  FILE *fp = fopen(file, "r");
  int gotargs = 0;
  if (fp == NULL) return 1;

  // defaults
  c->retries = BLIP_L2_RETRIES;

  while (fgets(real_buf, BUF_LEN, fp) != NULL) {
    buf = real_buf;
    rm_comment(buf);
    upd_start(&buf);
    if (sscanf(buf, "addr %s\n", arg) > 0) {
      inet_pton6(arg, &c->router_addr);
      gotargs ++;
    } else if (sscanf(buf, "proxy %s\n", c->proxy_dev) > 0) {
      gotargs ++;
    } else if (sscanf(buf, "channel %i\n", &c->channel) > 0) {
      if (c->channel < 11 || c->channel > 26) {
        fatal("Invalid channel specified in '%s'\n", file);
        exit(1);
      }
      gotargs ++;
    } else if (sscanf(buf, "log %s\n", arg) > 0) {
      int i;
      for (i = 0; i < 5; i++) {
        if (strncmp(log_names[i], arg, strlen(log_names[i])) == 0) {
          info("Read log level: %s\n", arg);
          log_setlevel(i);
          break;
        }
      }
    } else if (sscanf(buf, "retry %i\n", &c->retries) > 0) {
      if (c->retries <= 0 || c->retries > 25) {
        warn("retry value set to %i: outside of the recommended range (0,25]\n", c->retries);
      }
    } else if (*buf != '\0') {
      // anything else indicates that there's invalid input.
      return 1;
    }
  }
  fclose(fp);

  if (gotargs != 3) return 1;

  info("Read config from '%s'\r\n", file);
  if (strncmp(c->proxy_dev, "lo", 3) != 0) {
    info("Proxying neighbor advertisements to %s\r\n", c->proxy_dev);
  }
  info("Using channel %i\r\n", c->channel);
  info("Retries: %i\r\n", c->retries);
  lastconfig = c;
  return 0;
}
Example #3
0
int main(int argc, char *argv[]) {
	int level;
	int opt;
	int sock;

	while ((opt = getopt(argc, argv, "vhdp:l:")) != -1) {
		switch (opt) {
		case 'v':
			print_version();
			return 0;
		case 'h':
			print_usage();
			return 0;
		case 'd':
			g_debug_mode = !0;
			log_file = NULL;
			break;
		case 'p':
			g_rs_port = atoi(optarg);
			break;
		case 'l':
			level = atoi(optarg);
			if (level < 0 || level >= PINE_LOG_MAX) {
				exit(EXIT_FAILURE);
			}
			log_setlevel(level);
			break;
		default: /* ? */
			print_usage();
			exit(EXIT_FAILURE);
		}
	}

	if (log_init(log_file) < 0) {
		exit(EXIT_FAILURE);
	}
	if (!g_debug_mode) {
		if (daemon(0, 0) < 0) {
			perror("daemon()");
			exit(EXIT_FAILURE);
		}
	}

	logger(PINE_LOG_INFO, "start pined");

	sock = create_socket();
	if (sock < 0) {
		exit(EXIT_FAILURE);
	}

	signal(SIGPIPE, SIG_IGN);

	return do_pined(sock);
}
int main(int argc, char **argv) {
  char     print_buf[128], dev[IF_NAMESIZE];

  log_init();
  log_setlevel(LOGLVL_DEBUG);

  if (argc != 3) {
    fatal("%s <device> <rate>\n", argv[0]);
    exit(1);
  }

  queue_init(&pan_q);
  queue_init(&tun_q);
  init_reconstruct();
  
  if (config_parse("ieee154_interface.conf", &device_config)) {
    log_fatal_perror("parsing config file failed");
    exit(1);
  }

  /* set up the serial interface device */
  pthread_mutex_init(&pan_lock, NULL);
  if (setup_serial(argv[1], argv[2], &device_config)) {
    fatal("opening serial device failed!\n");
    exit(1);
  }

  snprintf(print_buf, 128, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", 
           device_config.eui64.data[0],device_config.eui64.data[1],device_config.eui64.data[2],
           device_config.eui64.data[3],device_config.eui64.data[4],device_config.eui64.data[5],
           device_config.eui64.data[6],device_config.eui64.data[7]);
  info("device EUI-64: %s\n", print_buf);

  pthread_create(&pan_writer, NULL, pan_write, NULL);
  pthread_create(&reconstruct_thread, NULL, age_reconstruct, NULL);

  /* initialize thes tun */
  tun_fd = tun_open(dev);
  if (tun_fd < 0) {
    log_fatal_perror("opening tun device failed");
    exit(1);
  }

  if (tun_setup(dev, device_config.eui64) < 0) {
    exit(1);
  }

  sleep(1);
  pthread_create(&tun_reader, NULL, tun_dev_read, NULL);
  pthread_create(&pan_reader, NULL, pan_read, NULL);
  
  pthread_join(pan_writer, NULL);
}
Example #5
0
int main(int argc, const char *argv[])
{
    /* open global logger to stderr (by setting filename to NULL) */
    log_open("example", NULL, 0);
    /* set log level to info, also the default level */
    log_setlevel(LOG_INFO);
    /* debug mesage won't be seen */
    log_debug("debug message");
    /* but info and warn message can be seen */
    log_info("info message");
    log_warn("warn message");
    return 0;
}
Example #6
0
int main(int argc, char *argv[]) {
    log_open("statsd-proxy", NULL, 0);

    char *filename;

    const char *short_opt = "hvdf:";
    struct option long_opt[] = {
        {"help", no_argument, NULL, 'h'},
        {"version", no_argument, NULL, 'v'},
        {"debug", no_argument, NULL, 'd'},
        {"file", required_argument, NULL, 'f'},
        {NULL, 0, NULL, 0},
    };

    int c;
    while ((c = getopt_long(argc, argv, short_opt, long_opt, NULL)) != -1) {
        switch (c) {
            case 'h':
            case ':':
            case '?':
                usage();
                break;
            case 'v':
                version();
                break;
            case 'f':
                filename = optarg;
                break;
            case 'd':
                log_setlevel(LOG_DEBUG);
                break;
            default:
                usage();
        };
    }

    if (argc == 1 || optind < argc) usage();

    struct config *config = config_new();

    if (config == NULL) exit(1);

    if (config_init(config, filename) != CONFIG_OK) exit(1);

    start(config);

    config_free(config);
    log_close();
    return 0;
}
Example #7
0
int main(int argc, const char *argv[]) {
    /* open global logger to stderr (by setting filename to NULL) */
    log_open("example", NULL, 0);
    /* set log level to info, also the default level */
    log_setlevel(LOG_INFO);
    /* debug mesage won't be seen */
    log_debug("debug message");
    /* but info and warn, error message can be seen */
    log_info("info message");
    log_warn("warn message");
    log_error("error message: %s", "someting wrong");
    /* will log trace back on segmentfault automatically */
    make_segmentfault();
    return 0;
}
Example #8
0
int main(int argc, char *argv[])
{
    if (0 != parse_options(argc, argv))
    {
        usage();
        return 1;
    }

    if (!verbose)
        log_setlevel(LOGLEVEL_CRITICAL);

    memset(&g_srvctx, 0, sizeof(g_srvctx));
    g_srvctx.loop = ev_default_loop(0);
    ev_set_userdata(g_srvctx.loop, &g_srvctx);

    if (NULL == (g_srvctx.timer_1hz = (struct ev_timer *)malloc(sizeof(struct ev_timer))))
        LOG_CRITICAL("out of mem");
    if (NULL == (g_srvctx.timer_10hz = (struct ev_timer *)malloc(sizeof(struct ev_timer))))
        LOG_CRITICAL("out of mem");
    if (NULL == (g_srvctx.idle_watcher = (struct ev_idle *)malloc(sizeof(struct ev_idle))))
        LOG_CRITICAL("out of mem");

    ev_timer_init(g_srvctx.timer_1hz, (void *)timeout_1hz_cb, 0, 1);
    ev_set_priority(g_srvctx.timer_1hz, EV_MAXPRI);
    ev_timer_start(g_srvctx.loop, g_srvctx.timer_1hz);
    ev_timer_init(g_srvctx.timer_10hz, (void *)timeout_10hz_cb, 0, 0.1);
    ev_set_priority(g_srvctx.timer_10hz, EV_MAXPRI);
    ev_timer_start(g_srvctx.loop, g_srvctx.timer_10hz);
    ev_idle_init(g_srvctx.idle_watcher, idle_cb);

    if (0 != serial_init(g_srvctx.loop, &(g_srvctx.serialctx), device_name))
    {
        LOG_CRITICAL("Failed to open %s", device_name);
    }

    if (0 != mqtt_connect(&(g_srvctx.mqttctx), CLIENT_NAME, server, port))
    {
        LOG_CRITICAL("failed to connect to server");
    }

    while(1)
    {
        ev_loop(g_srvctx.loop, 0);
    }

    return 0;
}
int main(void) {
    BUFFER * buffer;
    double din1, din2, dout1, dout2;
    int64_t lin1, lin2, lout1, lout2;
    char * sin1, *sin2;
    const char * sout1, * sout2;
    hessian_object_t * h_din1, * h_din2, * h_dout1, * h_dout2, * h_lin1, * h_lin2, * h_lout1, * h_lout2, * h_sin1, * h_sin2, * h_sout2, * h_sout1;
    din1= -0.678687687;
    din2= 123423.3423;
    lin1= 979798797798;
    lin2= -65422454;
    sin1= "";
    sin2= "heelo";
    printf("din1: %f\n",din1);
    printf("din2: %f\n",din2);
    h_din1= hessian_create(HESSIAN_DOUBLE, din1);
    h_din2= hessian_create(HESSIAN_DOUBLE, din2);
    printf("lin1: %ld\n",lin1);
    printf("lin2: %ld\n",lin2);
    h_lin1= hessian_create(HESSIAN_LONG, lin1);
    h_lin2= hessian_create(HESSIAN_LONG, lin2);
    printf("sin1: '%s'\n",sin1); 
    printf("sin2: '%s'\n",sin2); 
    h_sin1= hessian_create(HESSIAN_STRING, sin1);
    h_sin2= hessian_create(HESSIAN_STRING, sin2);
    buffer= buffer_create(1024);
    
    printf("serialize...\n");
    hessian_serialize(h_din1,buffer);
    hessian_serialize(h_din2,buffer);
    hessian_serialize(h_sin1,buffer);
    hessian_serialize(h_sin2,buffer);
    hessian_serialize(h_lin1,buffer);
    hessian_serialize(h_lin2,buffer);
    
    printf("deserialize...\n");
    h_dout1= hessian_deserialize(buffer);
    h_dout2= hessian_deserialize(buffer);
    h_sout1= hessian_deserialize(buffer);
    h_sout2= hessian_deserialize(buffer);
    h_lout1= hessian_deserialize(buffer);
    h_lout2= hessian_deserialize(buffer);

    dout1= hessian_double_getvalue(h_dout1);
    dout2= hessian_double_getvalue(h_dout2);
    lout1= hessian_long_getvalue(h_lout1);
    lout2= hessian_long_getvalue(h_lout2);
    sout1= hessian_string_getstring(h_sout1);
    sout2= hessian_string_getstring(h_sout2);
    printf("dout1: %f\n",dout1);
    printf("dout2: %f\n",dout2);
    printf("lout1: %ld\n",lout1);
    printf("lout2: %ld\n",lout2);
    printf("sout1: '%s'\n",sout1);
    printf("sout2: '%s'\n",sout2);
    
    printf("tests...\n");
    if (din1 != dout1) {
        printf("din1 (%f) != dout1 (%f)\n",din1,dout1);
        return 1;
    }
    if (din2 != dout2) {
        printf("din2 (%f) != dout2 (%f)\n",din2,dout2);
        return 1;
    }
    if (lin1 != lout1) {
        printf("lin1 (%ld) != lout1 (%ld)\n",lin1,lout1);
        return 2;
    }
    if (lin2 != lout2) {
        printf("lin2 (%ld) != lout2 (%ld)\n",lin2,lout2);
        return 2;
    }
    if (strcmp(sin1,sout1) != 0) {
        printf("sin1 '%s' != sout1 '%s'\n",sin1,sout1);
        return 3;
    }
    if (strcmp(sin2,sout2) != 0) {
        printf("sin2 '%s' != sout2 '%s'\n",sin2,sout2);
        return 3;
    }

/*
    const char * filename= "/tmp/java_hessian_resource.data";
    FILE * file;
    printf("test deserialization from Java serialization. Data: %s\n", filename);
    file= fopen(filename,"r");
    if (file==NULL) {
        printf("failed to open file: %s\n", filename);
        return 4;
    }
    buffer_reset(buffer);
    size_t size= buffer_fread(buffer,file);
    printf("%d bytes read from %s\n", (int)size, filename);
    
    log_setout(stderr);
    log_setlevel(LOG_LEVEL_TRACE);
    
    printf("deserialize hessian resource...\n");

    hessian_object_t * h_resource= hessian_deserialize(buffer);
    xacml_resource_t * resource;
    int io_rc= xacml_resource_unmarshal(&resource, h_resource);
    printf("result: %d\n",io_rc);
*/    



    printf("using: %s\n",pep_version());
    printf("base64 decoding and hessian deserialization test...\n");

    log_setout(stderr);
    log_setlevel(LOG_LEVEL_TRACE);

    const char * b64filename= "b64input1";
    FILE * b64file= fopen(b64filename,"r");
    if (b64file==NULL) {
        printf("failed to open b64 file: %s\n", b64filename);
        return 5;
    }
    BUFFER * b64input= buffer_create(1024);
    if (b64input==NULL) {
        printf("failed to create b64input buffer\n");
        return 5;
    }
    size_t size= buffer_fread(b64input,b64file);
    printf("%d bytes read from %s\n", (int)size, b64filename);
    
    BUFFER * input= buffer_create(1024);
    if (input==NULL) {
        printf("failed to create input buffer\n");
        return 5;
    }
    
    printf("base64 decode input buffer...\n");
    base64_decode(b64input,input);
    size= buffer_length(input);
    printf("%d bytes available in input buffer\n", (int)size);

    /* unmarshal the PEP response */
    xacml_response_t * response;
    pep_error_t unmarshal_rc= xacml_response_unmarshalling(&response,input);
    if ( unmarshal_rc != PEP_OK) {
        printf("pep_authorize: can't unmarshal the XACML response: %s.", pep_strerror(unmarshal_rc));
        buffer_delete(b64input);
        buffer_delete(input);
        return unmarshal_rc;
    }

    printf("hessian response deserialized from: %s.\n", b64filename);
    dump_xacml_request(stdout, xacml_response_getrequest(response));
    dump_xacml_response(stdout,response);


    printf("buffer tests...\n");
    BUFFER * buf= buffer_create(1024);
    buffer_delete(buf);
    if (buf == NULL) printf("buf is NULL\n");
    else printf("buf not NULL\n");

    return 0;
}
Example #10
0
int main(int argc, const char **argv) {
	log_printf(NORMAL, "Starting OpenMOC...");

	double k_eff;
	Timer timer;

	/* Create an options class to parse command line options */
	Options opts(argc, argv);

	/* Set the verbosity */
	log_setlevel(opts.getVerbosity());

	/* Initialize the parser and time the parser */
	timer.start();
	Parser parser(&opts);
	timer.stop();
	timer.recordSplit("Parsing input files");

	/* Initialize the geometry with surfaces, cells & materials */
	timer.reset();
	timer.start();
	Geometry geometry(&parser);
	timer.stop();
	timer.recordSplit("Geomery initialization");

	/* Print out geometry to console if requested at runtime*/
	if (opts.dumpGeometry())
		geometry.printString();

	/* Compress cross-sections if requested at runtime */
	if (opts.compressCrossSections())
		geometry.compressCrossSections();

	Plotter plotter(&geometry, opts.getBitDimension(), opts.getExtension());

	/* Initialize the trackgenerator */
	TrackGenerator track_generator(&geometry, &plotter, opts.getNumAzim(),
				       opts.getTrackSpacing());

	/* Generate tracks */
	timer.reset();
	timer.start();
	track_generator.generateTracks();
	track_generator.makeReflective();
	timer.stop();
	timer.recordSplit("Generating tracks");

	/* Segment tracks */
	timer.reset();
	timer.start();
	track_generator.segmentize();
	timer.stop();
	timer.recordSplit("Segmenting tracks");

	/* Fixed source iteration to solve for k_eff */
	Solver solver(&geometry, &track_generator, &plotter, opts.plotFluxes());
	timer.reset();
	timer.start();
	k_eff = solver.computeKeff(MAX_ITERATIONS);
	timer.stop();
	timer.recordSplit("Fixed source iteration");

	/* Compute pin powers if requested at run time */
	if (opts.computePinPowers())
		solver.computePinPowers();

	log_printf(RESULT, "k_eff = %f", k_eff);

	/* Print timer splits to console */
	log_printf(NORMAL, "Program complete");
	timer.printSplits();
}
Example #11
0
int main(int argc, char **argv) {
	SDL_Init(0);
	SDL_Thread *thread;

	int opt;
	t_rocsmq_message message;
	int x_it = 0;
	
	// parse config file 
	parseconfig(CONFIGFILE, &baseconfig, 0, 0 ,0);
	
	
	// open log
	log_message(DEBUG, "logging to file.. '%s'\n", baseconfig.logfile);
	openlog((char const *)baseconfig.clientname, (char const*)baseconfig.logfile);
	log_message(DEBUG, "loglevel = %d\n", baseconfig.loglevel);
		
	// set loglevel	
	log_setlevel(baseconfig.loglevel);
	
	log_message(DEBUG, "clientname: %s", baseconfig.clientname);
	strncpy (message.sender, baseconfig.clientname, 20);
	memset  (message.tail, 0, 1000);
	strncpy (message.id, "", ROCS_IDSIZE);

	// get command line options
	while ((opt = getopt(argc, argv, "n:i:m:f:x")) != -1) {
		switch(opt) {
			case 'n':
				strcpy(baseconfig.clientname, optarg);
				break;
			case 'i':
				strncpy(message.id,optarg, ROCS_IDSIZE);
				break;
			case 'm': 
				strncpy(message.tail,optarg, 1000);
				break;
			case 'x':
				x_it = 1;
				break;
			case 'f':
				parseconfig(optarg, &baseconfig,0, 0,0);	
			default:
				printf("usage:\n %s [-n name] [-i message-id] [-m message] [-x]\n", argv[0]);
				printf(" -n - name of the client\n");
				printf(" -i - identifier of the message\n");
				printf(" -m - body of the message\n");
				printf(" -x - exit after sending, goes into listening mode else.\n");
		}
		
	}


	sock = rocsmq_init(&baseconfig);
	if (!sock) {
		SDL_Quit();
		printf("could not connect to Server: %s\n", rocsmq_error());
		exit(1);
	}


	// start network listener
	thread = rocsmq_start_thread(sock);

	if (message.id != 0) {
			log_message( INFO, "sending message\n ->id:\t%d\n ->tail:\t'%s'\n",message.id, message.tail);
			if (! rocsmq_send(sock,&message,0)) {
				log_message(ERROR,"could not send: %s\n",rocsmq_error());
			}
	}

	if (! x_it) 
	while (rocsmq_thread_is_running()) {
		while(rocsmq_has_messages()) {

			rocsmq_get_message(&message);
			log_message( INFO, "incoming message\n ->id:\t%d\n ->tail:\t'%s'\n",message.id, message.tail);
			if (strcmp("quit",message.tail) == 0) {
				rocsmq_thread_set_running(0);
				log_message(INFO,"quitting..\n");
			}

		}
		SDL_Delay(100);
		printf(".");
	}

	rocsmq_destroy_thread(thread);
	rocsmq_exit(sock);
	SDL_Quit();
	return 0;
}
int main(int argc, const char **argv) {

	Options options(argc, argv);
	Timer timer;

	log_setlevel(options.getVerbosity());

	/* Get the number of neutrons, bins and batches */
	int num_neutrons = options.getNumNeutrons();
	int num_bins = options.getNumBins();
	int num_batches = options.getNumBatches();
    int num_threads = options.getNumThreads();
	int num_gen;
	int num_alive;

	log_printf(NORMAL, "Beginning two region problem with %d neutrons, "
			"%d bins, %d batches, %d threads...", num_neutrons, num_bins,
			num_batches, num_threads);

	/* Create a handle for plotting with gnuplot */
	gnuplot_ctrl* handle;


	/* Create a set of plotting flux bins for each batch */
	BatchBinSet* total_flux = new BatchBinSet();
	BatchBinSet* fuel_flux = new BatchBinSet();
	BatchBinSet* moderator_flux = new BatchBinSet();

	total_flux->createBinners(1E-6, 1E7, num_bins, num_batches,
							LOGARITHMIC, FLUX_ENERGY, (char*)"all");
	fuel_flux->createBinners(1E-6, 1E7, num_bins, num_batches,
							LOGARITHMIC, FLUX_ENERGY, (char*)"all");
	moderator_flux->createBinners(1E-6, 1E7, num_bins, num_batches,
							LOGARITHMIC, FLUX_ENERGY, (char*)"all");


	/* Create bins to compute total fission and absorption rates */
	BatchBinSet* tot_fiss_rate = new BatchBinSet();
	BatchBinSet* tot_abs_rate = new BatchBinSet();

	tot_fiss_rate->createBinners(1E-7, 1E7, 1, num_batches, EQUAL,
									FISSION_RATE_ENERGY, (char*)"all");
	tot_abs_rate->createBinners(1E-7, 1E7, 1, num_batches, EQUAL,
									ABSORPTION_RATE_ENERGY, (char*)"all");
	float nu_bar = 2.455;	/* CASMO edit for average # neutrons per fission */

	/* Create bins to compute two group cell-averaged cross-sections */
	BatchBinSet* capture_2G = new BatchBinSet();
	BatchBinSet* absorb_2G = new BatchBinSet();
	BatchBinSet* fission_2G = new BatchBinSet();
	BatchBinSet* elastic_2G = new BatchBinSet();
	BatchBinSet* total_2G = new BatchBinSet();
	BatchBinSet* two_group_flux = new BatchBinSet();

	float two_group_E_ranges[3] = {0.0, 0.625, 1E7};

	capture_2G->createBinners(two_group_E_ranges, 2, num_batches,
							CAPTURE_RATE_ENERGY, (char*)"all");
	absorb_2G->createBinners(two_group_E_ranges, 2, num_batches,
							ABSORPTION_RATE_ENERGY, (char*)"all");
	fission_2G->createBinners(two_group_E_ranges, 2, num_batches,
							FISSION_RATE_ENERGY, (char*)"all");
	elastic_2G->createBinners(two_group_E_ranges, 2, num_batches,
							ELASTIC_RATE_ENERGY, (char*)"all");
	total_2G->createBinners(two_group_E_ranges, 2, num_batches,
							COLLISION_RATE_ENERGY, (char*)"all");
	two_group_flux->createBinners(two_group_E_ranges, 2, num_batches,
									FLUX_ENERGY, (char*)"all");


	/* Create bins to compute two group isotopic cross-sections */
	BatchBinSet* H1_capture_rate_2G = new BatchBinSet();
	BatchBinSet* H1_elastic_rate_2G = new BatchBinSet();
	BatchBinSet* O16_elastic_rate_2G = new BatchBinSet();
	BatchBinSet* ZR90_elastic_rate_2G = new BatchBinSet();

	BatchBinSet* U235_capture_rate_2G = new BatchBinSet();
	BatchBinSet* U235_elastic_rate_2G = new BatchBinSet();
	BatchBinSet* U235_fission_rate_2G = new BatchBinSet();
	BatchBinSet* U238_capture_rate_2G = new BatchBinSet();
	BatchBinSet* U238_elastic_rate_2G = new BatchBinSet();
	BatchBinSet* U238_fission_rate_2G = new BatchBinSet();

	H1_capture_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										CAPTURE_RATE_ENERGY, (char*)"H1");
	H1_elastic_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										ELASTIC_RATE_ENERGY, (char*)"H1");
	O16_elastic_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										ELASTIC_RATE_ENERGY, (char*)"O16");
	ZR90_elastic_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										ELASTIC_RATE_ENERGY, (char*)"ZR90");

	U235_capture_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										CAPTURE_RATE_ENERGY, (char*)"U235");
	U235_elastic_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										ELASTIC_RATE_ENERGY, (char*)"U235");
	U235_fission_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										FISSION_RATE_ENERGY, (char*)"U235");
	U238_capture_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										CAPTURE_RATE_ENERGY, (char*)"U238");
	U238_elastic_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										ELASTIC_RATE_ENERGY, (char*)"U238");
	U238_fission_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
										FISSION_RATE_ENERGY, (char*)"U238");


	/* Create bins to compute moderator to fuel flux ratios */
	int num_ratios = 13;
	BatchBinSet* fuel_flux_ratio = new BatchBinSet();
	BatchBinSet* moderator_flux_ratio = new BatchBinSet();

	float flux_ratio_E_ranges[14] = {0.0, 0.1, 0.5, 1.0, 6.0, 10.0, 25.0,
									50.0, 100.0, 1000.0, 10000.0, 100000.0,
									500000.0, 10000000.0};

	fuel_flux_ratio->createBinners(flux_ratio_E_ranges, num_ratios,
							num_batches, FLUX_ENERGY, (char*)"all");

	moderator_flux_ratio->createBinners(flux_ratio_E_ranges, num_ratios,
							num_batches, FLUX_ENERGY, (char*)"all");


	/* Create bins to compute the diffusion coefficient for three methods */
	BatchBinSet* coll_rate_2G = new BatchBinSet();
	BatchBinSet* transport_rate_2G = new BatchBinSet();
	BatchBinSet* diffusion_rate_2G = new BatchBinSet();

	coll_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
								COLLISION_RATE_ENERGY, (char*)"all");
	transport_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
								TRANSPORT_RATE_ENERGY, (char*)"all");
	diffusion_rate_2G->createBinners(two_group_E_ranges, 2, num_batches,
								DIFFUSION_RATE_ENERGY, (char*)"all");


	/* 2-region pin cell geometric parameters (units in cm) */
	float r_fuel = 0.4096;
	float r_gap = 0.4178;
	float r_cladding = 0.4750;
	float pitch = 1.26;
	float p2 = pitch * pitch;

	/* 2-region homogenized densities (g/cm^3) and enrichment */
	float rho_fuel = 10.2;
	float rho_cladding = 6.549;
	float rho_coolant = 0.9966;
	float enrichment = 0.03035;

	/* Isotope number densities */
	float N_A = 6.023E23;	/* Avogadro's number (at / mol) */
	float N_U238 = rho_fuel*N_A*(1.0 - enrichment) / ((238.0 *
					(1.0 - enrichment)) + (235.0*enrichment) + (16.0*2.0));
	float N_U235 = rho_fuel*N_A*enrichment / ((238.0 *
					(1.0 - enrichment)) + (235.0*enrichment) + (16.0*2.0));
	float N_O16 = rho_fuel*N_A*2.0 / ((238.0 *
					(1.0 - enrichment)) + (235.0*enrichment) + (16.0*2.0));
	float N_ZR90 = rho_cladding*N_A / 90.0;
	float N_H2O = rho_coolant*N_A / 18.0;
	float N_H1 = rho_coolant*N_A*2.0 / 18.0;

	/* 2-region pin cell volumes (cm^3) */
	float v_fuel = M_PI*r_fuel*r_fuel;
	float v_gap = M_PI*(r_gap*r_gap - r_fuel*r_fuel);
	float v_cladding = M_PI*(r_cladding*r_cladding - r_gap*r_gap);
	float v_coolant = p2 - M_PI*r_cladding*r_cladding;
	float v_moderator = v_gap + v_cladding + v_coolant;
	float v_total = v_fuel + v_moderator;

	/* Compute homogenized moderator number densities using volume weighting */
	N_H2O *= (v_coolant / v_moderator);
	N_H1 *= (v_coolant / v_moderator);
	N_ZR90 *= (v_cladding / v_moderator);

	/* Dancoff factor from CASMO-5 */
	float dancoff = 0.277;

	/* Escape cross-section */
	float sigma_e = 1.0 / (2.0*r_fuel);

	/* Carlvik's two-term rational model */
	float A = (1.0 - dancoff) / dancoff;
	float alpha1 = ((5.0*A + 6.0) - sqrt(A*A + 36.0*A + 36.0)) /
														(2.0*(A+1.0));
	float alpha2 = ((5.0*A + 6.0) + sqrt(A*A + 36.0*A + 36.0)) /
														(2.0*(A+1.0));
	float beta = (((4.0*A + 6.0) / (A + 1.0)) - alpha1) / (alpha2 - alpha1);

	/* Print out the geometry parameters */
	log_printf(NORMAL, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "\t\t\t\tGeometry Parameters (cm)");
	log_printf(NORMAL, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "");
	log_printf(NORMAL, "r_fuel = %f", r_fuel);
	log_printf(NORMAL, "r_gap  = %f", r_gap);
	log_printf(NORMAL, "r_cladding = %f", r_cladding);
	log_printf(NORMAL, "pitch = %f", pitch);
	log_printf(NORMAL, "total cell area = %f", p2);
	log_printf(NORMAL, "v_fuel = %f", v_fuel);
	log_printf(NORMAL, "v_gap = %f", v_gap);
	log_printf(NORMAL, "v_cladding = %f", v_cladding);
	log_printf(NORMAL, "v_coolant = %f", v_coolant);
	log_printf(NORMAL, "v_moderator = %f", v_moderator);
	log_printf(NORMAL, "v_total = %f", v_total);
	log_printf(NORMAL, "");

	/* Print to the console the number densities */
	log_printf(NORMAL, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "\t\t\t\tNumber Densities (at/cm^3)");
	log_printf(NORMAL, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "");
	log_printf(NORMAL, "H1:\t%1.5e", N_H1);
	log_printf(NORMAL, "H2O:\t%1.5e", N_H2O);
	log_printf(NORMAL, "ZR90:\t%1.5e", N_ZR90);
	log_printf(NORMAL, "U235:\t%1.5e", N_U235);
	log_printf(NORMAL, "U238:\t%1.5e", N_U238);
	log_printf(NORMAL, "O16:\t%1.5e", N_O16);
	log_printf(NORMAL, "");

	/* Print to the console the collision probability parameters */
	log_printf(NORMAL, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "\t\t\tTwo Region Collision Probability Parameters");
	log_printf(NORMAL, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "");
	log_printf(NORMAL, "dancoff = %f", dancoff);
	log_printf(NORMAL, "sigma_e = %f", sigma_e);
	log_printf(NORMAL, "A = %f", A);
	log_printf(NORMAL, "alpha1 = %f", alpha1);
	log_printf(NORMAL, "alpha2 = %f", alpha2);
	log_printf(NORMAL, "beta = %f", beta);
	log_printf(NORMAL, "");


	/* Create isotopes*/
	char* delim = (char*)"\t";

	Isotope* H1 = new Isotope();
	H1->setA(1);
	H1->setIsotopeType((char*)"H1");
	H1->loadXS((char*)"pendf/h-1_capture.txt", CAPTURE, delim);
	H1->loadXS((char*)"pendf/h-1_elastic.txt", ELASTIC, delim);
	H1->setElasticAngleType(ISOTROPIC_LAB);
	H1->initializeThermalScattering(1E-6, 15, 1000, 15);

	Isotope* O16 = new Isotope();
	O16->setA(16);
	O16->setIsotopeType((char*)"O16");
	O16->loadXS((char*)"pendf/o-16_elastic.txt", ELASTIC, delim);
	O16->setElasticAngleType(ISOTROPIC_LAB);

	Isotope* ZR90 = new Isotope();
	ZR90->setA(90);
	ZR90->setIsotopeType((char*)"ZR90");
	ZR90->loadXS((char*)"pendf/zr-90_elastic.txt", ELASTIC, delim);
	ZR90->setElasticAngleType(ISOTROPIC_LAB);

	Isotope* U235 = new Isotope();
	U235->setA(235);
	U235->setIsotopeType((char*)"U235");
	U235->loadXS((char*)"pendf/u-235_capture.txt", CAPTURE, delim);
	U235->setOneGroupElasticXS(11.4, ISOTROPIC_LAB);
	U235->loadXS((char*)"pendf/u-235_fission.txt", FISSION, delim);

	Isotope* U238 = new Isotope();
	U238->setA(238);
	U238->setIsotopeType((char*)"U238");
	U238->loadXS((char*)"pendf/u-238_capture.txt", CAPTURE, delim);
	U238->setOneGroupElasticXS(11.3, ISOTROPIC_LAB);
	U238->loadXS((char*)"pendf/u-238_fission.txt", FISSION, delim);


	/* Create Materials */
	Material* moderator = new Material[num_threads];
	Material* fuel = new Material[num_threads];


	/* Create Regions for each thread */
	Region1D* pellet = new Region1D[num_threads];
	Region1D* coolant = new Region1D[num_threads];

	/* Create Fissioners for each thread */
	Fissioner* fissioners = new Fissioner[num_threads];

	/* Create Region class objects for each thread */
	for (int i=0; i < num_threads; i++) {

		/* Initialize Materials for each thread with isotope clones */
		moderator[i].setMaterialName((char*)"moderator");
		fuel[i].setMaterialName((char*)"fuel");

		moderator[i].addIsotope(ZR90->clone(), N_ZR90);
		moderator[i].addIsotope(H1->clone(), N_H1);
		moderator[i].addIsotope(O16->clone(), N_H2O);
		moderator[i].rescaleCrossSections(1E-7, 1E7, 50000, LOGARITHMIC);

		fuel[i].addIsotope(U235->clone(), N_U235);
		fuel[i].addIsotope(U238->clone(), N_U238);
		fuel[i].addIsotope(O16->clone(), N_O16);
		fuel[i].rescaleCrossSections(1E-7, 1E7, 50000, LOGARITHMIC);

		/* Set the two region collision probability parameters */
		pellet[i].setRegionName((char*)"pellet");
		pellet[i].setMaterial(&fuel[i]);
		pellet[i].setAsFuel();
		pellet[i].setOtherPinCellRegion(&coolant[i]);
		pellet[i].setVolume(v_fuel);
		pellet[i].setTwoRegionPinCellParams(sigma_e, beta, alpha1, alpha2);

		coolant[i].setRegionName((char*)"coolant");
		coolant[i].setMaterial(&moderator[i]);
		coolant[i].setAsModerator();
		coolant[i].setOtherPinCellRegion(&pellet[i]);
		coolant[i].setVolume(v_moderator);
		coolant[i].setTwoRegionPinCellParams(sigma_e, beta, alpha1, alpha2);

		/* Set the fissioner class for this thread to have 10MeV maximum and
		 * 5000 sample bins */
		fissioners[i].setEMax(10.0);
		fissioners[i].setNumBins(200);
		fissioners[i].buildCDF();
	}


	/* Run the simulation */
	log_printf(NORMAL, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "\t\t\t\tBeginning Simulation...");
	log_printf(NORMAL, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "");

	timer.start();

	omp_set_num_threads(num_threads);
	#pragma omp parallel shared(total_flux, fuel_flux, moderator_flux,\
							fuel_flux_ratio, moderator_flux_ratio,\
							tot_fiss_rate, tot_abs_rate, U235_capture_rate_2G,\
							U235_elastic_rate_2G, U235_fission_rate_2G,\
							U238_capture_rate_2G, U238_elastic_rate_2G,\
							U238_fission_rate_2G, H1_capture_rate_2G,\
							H1_elastic_rate_2G, O16_elastic_rate_2G,\
							ZR90_elastic_rate_2G, fuel, moderator, \
							pellet, coolant, fissioners)
	{
		/* Loop over batches */
		#pragma omp for private(num_gen, num_alive)
		for (int b=0; b < num_batches; b++) {

			int thread_num = omp_get_thread_num();
			log_printf(NORMAL, "Batch: %d\tThread: %d", b, thread_num);

			/* Set the binns for this batch */
			pellet[thread_num].clearBinners();
			pellet[thread_num].addBinner(total_flux->getBinner(b));
			pellet[thread_num].addBinner(fuel_flux->getBinner(b));
			pellet[thread_num].addBinner(fuel_flux_ratio->getBinner(b));
			pellet[thread_num].addBinner(tot_fiss_rate->getBinner(b));
			pellet[thread_num].addBinner(tot_abs_rate->getBinner(b));
			pellet[thread_num].addBinner(U235_capture_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(U235_elastic_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(U235_fission_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(U238_capture_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(U238_elastic_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(U238_fission_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(O16_elastic_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(two_group_flux->getBinner(b));
			pellet[thread_num].addBinner(coll_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(transport_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(diffusion_rate_2G->getBinner(b));
			pellet[thread_num].addBinner(capture_2G->getBinner(b));
			pellet[thread_num].addBinner(fission_2G->getBinner(b));
			pellet[thread_num].addBinner(absorb_2G->getBinner(b));
			pellet[thread_num].addBinner(elastic_2G->getBinner(b));
			pellet[thread_num].addBinner(total_2G->getBinner(b));

			coolant[thread_num].clearBinners();
			coolant[thread_num].addBinner(total_flux->getBinner(b));
			coolant[thread_num].addBinner(moderator_flux->getBinner(b));
			coolant[thread_num].addBinner(moderator_flux_ratio->getBinner(b));
			coolant[thread_num].addBinner(tot_fiss_rate->getBinner(b));
			coolant[thread_num].addBinner(tot_abs_rate->getBinner(b));
			coolant[thread_num].addBinner(H1_capture_rate_2G->getBinner(b));
			coolant[thread_num].addBinner(H1_elastic_rate_2G->getBinner(b));
			coolant[thread_num].addBinner(O16_elastic_rate_2G->getBinner(b));
			coolant[thread_num].addBinner(ZR90_elastic_rate_2G->getBinner(b));
			coolant[thread_num].addBinner(two_group_flux->getBinner(b));
			coolant[thread_num].addBinner(coll_rate_2G->getBinner(b));
			coolant[thread_num].addBinner(transport_rate_2G->getBinner(b));
			coolant[thread_num].addBinner(diffusion_rate_2G->getBinner(b));
			coolant[thread_num].addBinner(capture_2G->getBinner(b));
			coolant[thread_num].addBinner(fission_2G->getBinner(b));
			coolant[thread_num].addBinner(absorb_2G->getBinner(b));
			coolant[thread_num].addBinner(elastic_2G->getBinner(b));
			coolant[thread_num].addBinner(total_2G->getBinner(b));

			/* Initialize all neutrons for this batch and add them to slab 1 */
			for (int n=0; n < num_neutrons; n++) {
				neutron* new_neutron = initializeNewNeutron();
				new_neutron->_x = 0.0;
				new_neutron->_mu = (float(rand()) / RAND_MAX) * 2.0 - 1.0;
				new_neutron->_energy = fissioners[thread_num].emitNeutroneV();
				pellet[thread_num].addNeutron(new_neutron);
			}

			/* Loop over all neutrons until they are all dead */
			num_gen = 1;
			num_alive = num_neutrons;

			while (num_alive > 0) {

				log_printf(DEBUG, "batch = %d, thread = %d, gen = %d, "
						"num_alive = %d", b, thread_num, num_gen, num_alive);

				num_gen++;
				num_alive = 0;

				/* Transfer neutrons between regions based on
				 * two region collision probabilities */
				pellet[thread_num].twoRegionNeutronTransferral();
				coolant[thread_num].twoRegionNeutronTransferral();

				/* Update each region's vector of neutrons with those
				 * neutrons which were just transferred */
				pellet[thread_num].initializeTransferredNeutrons();
				coolant[thread_num].initializeTransferredNeutrons();

				/* Move neutrons within each region */
				pellet[thread_num].moveNeutrons();
				coolant[thread_num].moveNeutrons();

				num_alive = pellet[thread_num].getNumNeutrons() +
							coolant[thread_num].getNumNeutrons();
			}
		}
	}

	log_printf(NORMAL, "");

	/* Stop the timer record the timing split for this simulation */
	timer.stop();
	timer.recordSplit("Pset 4 time (sec)");

	/* Compute batch statistics for total flux and flux in fuel, moderator */
	total_flux->computeScaledBatchStatistics(num_neutrons*v_total);
	fuel_flux->computeScaledBatchStatistics(num_neutrons*v_fuel);
	moderator_flux->computeScaledBatchStatistics(num_neutrons*v_moderator);

	/* Compute batch statistics for total fission and absorption rates */
	tot_fiss_rate->computeScaledBatchStatistics(num_neutrons*v_total);
	tot_abs_rate->computeScaledBatchStatistics(num_neutrons*v_total);

	/* Compute batch statistics for cell-averaged macro cross-sections */
	capture_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	fission_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	absorb_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	elastic_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	total_2G->computeScaledBatchStatistics(num_neutrons*v_total);

	/* Compute batch statistics for one group cross-sections */
	H1_capture_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	H1_elastic_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	O16_elastic_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	ZR90_elastic_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	U235_capture_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	U235_elastic_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	U235_fission_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	U238_capture_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	U238_elastic_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	U238_fission_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	two_group_flux->computeScaledBatchStatistics(num_neutrons*v_total);
	coll_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	transport_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);
	diffusion_rate_2G->computeScaledBatchStatistics(num_neutrons*v_total);

	/* Compute k-infinity */
	float fiss_rate_mu = tot_fiss_rate->getBatchMu()[0];
	float fiss_rate_var = tot_fiss_rate->getBatchVariance()[0];
	float abs_rate_mu = tot_abs_rate->getBatchMu()[0];
	float abs_rate_var = tot_abs_rate->getBatchVariance()[0];

	float k_inf = fiss_rate_mu * nu_bar / abs_rate_mu;

	float k_inf_var = (fiss_rate_mu*fiss_rate_mu)*abs_rate_var +
						(abs_rate_mu*abs_rate_mu)*fiss_rate_var +
									fiss_rate_var*abs_rate_var;

	float k_inf_std_dev = sqrt(k_inf_var);

	/* Compute moderator to fuel flux ratios */
	fuel_flux_ratio->computeScaledBatchStatistics(num_neutrons*v_fuel);
	moderator_flux_ratio->computeScaledBatchStatistics(num_neutrons*v_moderator);
	fuel_flux_ratio->computeScaledBatchStatistics(num_neutrons*v_fuel);
	moderator_flux_ratio->computeScaledBatchStatistics(num_neutrons*v_moderator);

	/* Print to the console the total fission rate */
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "\t\t\tTotal Fission Rate (Batch Statistics)");
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(NORMAL, "");
	log_printf(RESULT, "Tot fission rate = %1.8f\t\tVariance = %1.8f",
									tot_fiss_rate->getBatchMu()[0],
									tot_fiss_rate->getBatchVariance()[0]);
	log_printf(RESULT, "Tot absorption rate = %f\t\tVariance = %f",
									tot_abs_rate->getBatchMu()[0],
									tot_abs_rate->getBatchVariance()[0]);
	log_printf(RESULT, "k_inf = %f\t\tvariance = %1.8f \t\t 2 sigma = %1.8f", k_inf,
													k_inf_var, k_inf_std_dev);
	log_printf(RESULT, "");

	/* Print to the console the moderator/fuel flux ratios */
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "\t\t\t\tModerator/Fuel Flux Ratios");
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "");

	float ratio;
	for (int i=1; i < num_ratios+1; i++) {

		ratio = moderator_flux_ratio->getBatchMu()[i-1] /
						fuel_flux_ratio->getBatchMu()[i-1];

		log_printf(RESULT, "[%2.e eV - %2.e eV]:\t%f",
				flux_ratio_E_ranges[i-1], flux_ratio_E_ranges[i], ratio);
	}

	log_printf(RESULT, "");


	/* Print to the console the cell-averaged fast to thermal flux ratio */
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "\t\t\tCell-Averaged Fast-to-Thermal Flux Ratio");
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "");
	double* two_group_flux_mu = two_group_flux->getBatchMu();
	double flux1 = two_group_flux_mu[0];
	double flux2 = two_group_flux_mu[1];
	log_printf(RESULT, "Ratio = %f", flux2 / flux1);
	log_printf(RESULT, "");


	/* Print to the console the two group macroscopic cross-sections */
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "\t\tTwo Group Macroscopic Cross-Sections (cm^-1)");
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "");

	float xs1, xs2;

	log_printf(RESULT, "\t\t\t[%1.1f eV - %1.3f eV]\t[%1.3f eV - %1.1e eV]",
						two_group_flux->getBinner(0)->getBinEdges()[0],
						two_group_flux->getBinner(0)->getBinEdges()[1],
						two_group_flux->getBinner(0)->getBinEdges()[1],
						two_group_flux->getBinner(0)->getBinEdges()[2]);

	/* H1 capture */
	xs1 = H1_capture_rate_2G->getBatchMu()[0] / flux1;
	xs2 = H1_capture_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "H1 Capture: \t\t%f\t\t%f", xs1, xs2);

	/* H1 elastic */
	xs1 = H1_elastic_rate_2G->getBatchMu()[0] / flux1;
	xs2 = H1_elastic_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "H1 Elastic: \t\t%f\t\t%f", xs1, xs2);

	/* O16 elastic */
	xs1 = O16_elastic_rate_2G->getBatchMu()[0] / flux1;
	xs2 = O16_elastic_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "O16 Elastic: \t\t%f\t\t%f", xs1, xs2);

	/* ZR90 elastic */
	xs1 = ZR90_elastic_rate_2G->getBatchMu()[0] / flux1;
	xs2 = ZR90_elastic_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "ZR90 Elastic: \t\t%f\t\t%f", xs1, xs2);

	/* U235 capture */
	xs1 = U235_capture_rate_2G->getBatchMu()[0] / flux1;
	xs2 = U235_capture_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "U235 Capture: \t\t%f\t\t%f", xs1, xs2);

	/* U235 elastic */
	xs1 = U235_elastic_rate_2G->getBatchMu()[0] / flux1;
	xs2 = U235_elastic_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "U235 Elastic: \t\t%f\t\t%f", xs1, xs2);

	/* U235 fission */
	xs1 = U235_fission_rate_2G->getBatchMu()[0] / flux1;
	xs2 = U235_fission_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "U235 Fission: \t\t%f\t\t%f", xs1, xs2);

	/* U238 capture */
	xs1 = U238_capture_rate_2G->getBatchMu()[0] / flux1;
	xs2 = U238_capture_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "U238 Capture: \t\t%f\t\t%f", xs1, xs2);

	/* U238 elastic */
	xs1 = U238_elastic_rate_2G->getBatchMu()[0] / flux1;
	xs2 = U238_elastic_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "U238 Elastic: \t\t%f\t\t%f", xs1, xs2);

	/* U238 fission */
	xs1 = U238_fission_rate_2G->getBatchMu()[0] / flux1;
	xs2 = U238_fission_rate_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "U238 Fission: \t\t%f\t\t%f", xs1, xs2);

	log_printf(RESULT, "");


	/* Print to the console the two group macroscopic cross-sections */
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "\tTwo Group Cell-Averaged Macroscopic "
			"Cross-Sections (cm^-1)");
	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "");

	log_printf(RESULT, "\t\t\t[%1.1f eV - %1.3f eV]\t[%1.3f eV - %1.1e eV]",
						two_group_flux->getBinner(0)->getBinEdges()[0],
						two_group_flux->getBinner(0)->getBinEdges()[1],
						two_group_flux->getBinner(0)->getBinEdges()[1],
						two_group_flux->getBinner(0)->getBinEdges()[2]);

	/* Flux */
	log_printf(RESULT, "Flux: \t\t\t%f\t\t%f", flux1, flux2);

	/* Capture */
	xs1 = capture_2G->getBatchMu()[0] / flux1;
	xs2 = capture_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "Capture: \t\t\t%f\t\t%f", xs1, xs2);

	/* Fission */
	xs1 = fission_2G->getBatchMu()[0] / flux1;
	xs2 = fission_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "Fission: \t\t\t%f\t\t%f", xs1, xs2);

	/* Absorption */
	xs1 = absorb_2G->getBatchMu()[0] / flux1;
	xs2 = absorb_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "Absorb: \t\t\t%f\t\t%f", xs1, xs2);

	/* Elastic */
	xs1 = elastic_2G->getBatchMu()[0] / flux1;
	xs2 = elastic_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "Elastic: \t\t\t%f\t\t%f", xs1, xs2);

	/* Total */
	xs1 = total_2G->getBatchMu()[0] / flux1;
	xs2 = total_2G->getBatchMu()[1] / flux2;
	log_printf(RESULT, "Total: \t\t\t%f\t\t%f", xs1, xs2);
	log_printf(RESULT, "");


	/* Print to the console the two group macroscopic cross-sections */
	log_printf(RESULT, "*******************************************************"
												"*************************");
	log_printf(RESULT, "\t\t\tTwo Group Diffusion Coefficients");
	log_printf(RESULT, "*******************************************************"
												"*************************");
	log_printf(RESULT, "");
	log_printf(RESULT, "\t\t\t[%1.1f eV - %1.3f eV]\t[%1.3f eV - %1.1e eV]",
						two_group_flux->getBinner(0)->getBinEdges()[0],
						two_group_flux->getBinner(0)->getBinEdges()[1],
						two_group_flux->getBinner(0)->getBinEdges()[1],
						two_group_flux->getBinner(0)->getBinEdges()[2]);

	float sigma_t1, sigma_t2;
	float sigma_tr1, sigma_tr2;
	float D1, D2;

	sigma_t1 = coll_rate_2G->getBatchMu()[0] / flux1;
	sigma_t2 = coll_rate_2G->getBatchMu()[1] / flux2;
	D1 = 1.0 / (3.0 * sigma_t1);
	D2 = 1.0 / (3.0 * sigma_t2);

	log_printf(RESULT, "1/(3*sigma_t):\t\t%f\t\t%f", D1, D2);

	sigma_tr1 = transport_rate_2G->getBatchMu()[0] / flux1;
	sigma_tr2  = transport_rate_2G->getBatchMu()[1] / flux2;
	D1 = 1.0 / (3.0 * sigma_tr1);
	D2 = 1.0 / (3.0 * sigma_tr2);

	log_printf(RESULT, "1/(3*sigma_tr):\t\t%f\t\t%f", D1, D2);

	D1 = diffusion_rate_2G->getBatchMu()[0] / flux1;
	D2 = diffusion_rate_2G->getBatchMu()[1] / flux2;

	log_printf(RESULT, "Diff coeff:\t\t%f\t\t%f", D1, D2);

	log_printf(RESULT, "");


	/* Plot the total neutron flux */
	handle = gnuplot_init();
	gnuplot_set_xlabel(handle, (char*)"Energy (eV)");
	gnuplot_set_ylabel(handle, (char*)"flux");
	gnuplot_set_xrange(handle, 0.005, 1E7);
	gnuplot_cmd(handle, (char*)"set logscale xy");
	gnuplot_cmd(handle, (char*)"set title \"Normalized Flux\"");
	gnuplot_setstyle(handle, (char*)"lines");
	gnuplot_plot_xy(handle, total_flux->getBinner(0)->getBinCenters(),
			total_flux->getBatchMu(), num_bins, (char*)"Total Flux");
	gnuplot_plot_xy(handle, fuel_flux->getBinner(0)->getBinCenters(),
			fuel_flux->getBatchMu(), num_bins, (char*)"Fuel Flux");
	gnuplot_saveplot(handle, (char*)"flux");
	gnuplot_plot_xy(handle, moderator_flux->getBinner(0)->getBinCenters(),
			moderator_flux->getBatchMu(), num_bins, (char*)"Moderator Flux");
	gnuplot_close(handle);


	/* Free all allocated memory */
	delete [] pellet;
	delete [] coolant;
	delete [] fissioners;

	delete [] moderator;
	delete [] fuel;

	delete total_flux;
	delete fuel_flux;
	delete moderator_flux;
	delete tot_fiss_rate;
	delete tot_abs_rate;
	delete fuel_flux_ratio;
	delete moderator_flux_ratio;
	delete H1_capture_rate_2G;
	delete H1_elastic_rate_2G;
	delete O16_elastic_rate_2G;
	delete U235_capture_rate_2G;
	delete U235_elastic_rate_2G;
	delete U235_fission_rate_2G;
	delete U238_capture_rate_2G;
	delete U238_elastic_rate_2G;
	delete U238_fission_rate_2G;
	delete ZR90_elastic_rate_2G;
	delete two_group_flux;
	delete coll_rate_2G;
	delete transport_rate_2G;
	delete diffusion_rate_2G;

	delete H1;
	delete O16;
	delete ZR90;
	delete U235;
	delete U238;

	log_printf(RESULT, "*******************************************************"
													"*************************");
	log_printf(RESULT, "\t\t\t\tTiming Results");
	log_printf(RESULT, "*******************************************************"
													"*************************");
	timer.printSplits();
}