Example #1
0
void net_connect(net *n, buffer *b, int c)
{
  b->size = 0;
  buffer_add_string(b, "s=");
  buffer_add_string(b, n->session);
  buffer_add_char(b, 0);
  net_post(n, c, b,
           "https://webchat.freenode.net/dynamic/test/e/s",
           b->data);
}
Example #2
0
int rrdc_flush (const char *filename) /* {{{ */
{
  char buffer[4096];
  char *buffer_ptr;
  size_t buffer_free;
  size_t buffer_size;
  rrdc_response_t *res;
  int status;
  char file_path[PATH_MAX];

  if (filename == NULL)
    return (-1);

  memset (buffer, 0, sizeof (buffer));
  buffer_ptr = &buffer[0];
  buffer_free = sizeof (buffer);

  status = buffer_add_string ("flush", &buffer_ptr, &buffer_free);
  if (status != 0)
    return (ENOBUFS);

  pthread_mutex_lock (&lock);
  filename = get_path (filename, file_path);
  if (filename == NULL)
  {
    pthread_mutex_unlock (&lock);
    return (-1);
  }

  status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
  if (status != 0)
  {
    pthread_mutex_unlock (&lock);
    return (ENOBUFS);
  }

  assert (buffer_free < sizeof (buffer));
  buffer_size = sizeof (buffer) - buffer_free;
  assert (buffer[buffer_size - 1] == ' ');
  buffer[buffer_size - 1] = '\n';

  res = NULL;
  status = request (buffer, buffer_size, &res);
  pthread_mutex_unlock (&lock);

  if (status != 0)
    return (status);

  status = res->status;
  response_free (res);

  return (status);
} /* }}} int rrdc_flush */
Example #3
0
//---------------------------------------------------------------------------
int enviar_infoReduce_job(int socket_job,t_reduce_dest* reduce_dest, t_reduce_nodo_dest* nodo_host) {
	int result = 1;

	t_buffer* reduce_to_Nodo_buff;
	reduce_to_Nodo_buff = buffer_create_with_protocol(EXECUTE_REDUCE);

	buffer_add_int(reduce_to_Nodo_buff, nodo_host->id_nodo);
	buffer_add_string(reduce_to_Nodo_buff, reduce_dest->temp_file_name);
	buffer_add_int(reduce_to_Nodo_buff, list_size(nodo_host->path_temps));

	void _buffer_add_path(char* path) {
		buffer_add_string(reduce_to_Nodo_buff, path);
	}
Example #4
0
static uint8_t *encode_html(uint8_t *data, uint64_t data_length, uint64_t *out_length)
{
  int i;
  buffer_t *b = buffer_create(BO_HOST);
  char tmp[16];

  for(i = 0; i < data_length; i++)
  {
    if(isalnum(data[i]))
    {
      /* If the character is alphanumeric, add it as-is. */
      buffer_add_int8(b, data[i]);
    }
    else if(data[i] == ' ')
    {
      /* If the character is a space, add a '+'. */
      buffer_add_int8(b, '+');
    }
    else
    {
      /* Otherwise, encode it as a % followed by a hex code. */
      sprintf(tmp, "%%%02x", data[i]);
      buffer_add_string(b, tmp);
    }
  }

  return buffer_create_string_and_destroy(b, out_length);
}
Example #5
0
void buffer_add_cchar(buffer *b, int c)
{
  char t[32];
  if (isunreserved(c))
    buffer_add_char(b, c);
  else {
    sprintf(t, "%%%02X", (unsigned char)c);
    buffer_add_string(b, t);
  }
}
Example #6
0
void buffer_add_cstring(buffer *b, const char *c)
{
  char t[32];
  while (*c) {
    if (isunreserved(*c))
      buffer_add_char(b, *c);
    else {
      sprintf(t, "%%%02X", (unsigned char)*c);
      buffer_add_string(b, t);
    }
    c++;
  }
}
Example #7
0
static int buffer_add_value (const char *value, /* {{{ */
    char **buffer_ret, size_t *buffer_size_ret)
{
  char temp[4096];

  if (strncmp (value, "N:", 2) == 0)
    snprintf (temp, sizeof (temp), "%lu:%s",
        (unsigned long) time (NULL), value + 2);
  else
    strncpy (temp, value, sizeof (temp));
  temp[sizeof (temp) - 1] = 0;

  return (buffer_add_string (temp, buffer_ret, buffer_size_ret));
} /* }}} int buffer_add_value */
Example #8
0
static uint8_t *encode_cstr_pure(uint8_t *data, uint64_t data_length, uint64_t *out_length)
{
  int i;
  buffer_t *b = buffer_create(BO_HOST);
  char tmp[16];

  /* Encode every character as \xNN. */
  for(i = 0; i < data_length; i++)
  {
    sprintf(tmp, "\\x%02x", data[i]);
    buffer_add_string(b, tmp);
  }

  return buffer_create_string_and_destroy(b, out_length);
}
Example #9
0
void buffer_add_3d_device_data(struct buffer *buf,struct device *in,gdouble ***data)
{
int x=0;
int y=0;
int z=0;

gdouble xpos=0.0;
gdouble ypos=0.0;
gdouble zpos=0.0;

char string[200];

sprintf(string,"#data\n");
buffer_add_string(buf,string);
			
if ((in->xmeshpoints>1)&&(in->ymeshpoints>1)&&(in->zmeshpoints>1))
{
	for (z=0;z<in->zmeshpoints;z++)
	{
		for (x=0;x<in->xmeshpoints;x++)
		{
			for (y=0;y<in->ymeshpoints;y++)
			{
				sprintf(string,"%Le %Le %Le %Le\n",in->xmesh[x],in->ymesh[y],in->zmesh[z],data[z][x][y]);
				buffer_add_string(buf,string);
			}
		}
	}
}else
if ((in->xmeshpoints>1)&&(in->ymeshpoints>1))
{
	z=0;
	for (x=0;x<in->xmeshpoints;x++)
	{
		for (y=0;y<in->ymeshpoints;y++)
		{
			sprintf(string,"%Le %Le %Le\n",in->xmesh[x],in->ymesh[y],data[z][x][y]);
			buffer_add_string(buf,string);
		}
		buffer_add_string(buf,"\n");
	}
}else
{
	x=0;
	z=0;
	for (y=0;y<in->ymeshpoints;y++)
	{
		sprintf(string,"%Le %Le\n",in->ymesh[y],data[z][x][y]);
		buffer_add_string(buf,string);
	}
}

sprintf(string,"#end\n");
buffer_add_string(buf,string);
}
Example #10
0
/* Note: This function isn't tested, so be careful about messing around! */
static uint8_t *encode_fancy(uint8_t *data, uint64_t data_length, uint64_t *out_length)
{
  uint64_t i, j;
  buffer_t *b = buffer_create(BO_HOST);
  char tmp[64];

  for(i = 0; i < data_length; i++)
  {
    if((i % 16) == 0) /* if i is a multiple of 16... */
    {
      if(i > 0)
      {
        sprintf(tmp, "   ");
        buffer_add_string(b, tmp);
        for(j = 16; j > 0; j--)
          buffer_add_int8(b, get_character_from_byte(data[i - j]));
      }
      sprintf(tmp, "\n%04X: ", (uint16_t)i);
      buffer_add_string(b, tmp);
    }

    sprintf(tmp, "%02X ", data[i]);
    buffer_add_string(b, tmp);
  }

  if((i % 16) == 0)
  {
    sprintf(tmp, "   ");
    buffer_add_string(b, tmp);
    for(j = 16; j > 0; j--)
      buffer_add_int8(b, get_character_from_byte(data[i - j]));
  }
  else
  {
    /* Add padding spaces. */
    for(i = data_length % 16; i < 17; i++)
      buffer_add_string(b, "   ");

    for(i = data_length - (data_length % 16); i < data_length; i++)
      buffer_add_int8(b, get_character_from_byte(data[i]));
  }


  sprintf(tmp, "\nLength: 0x%"PRIX64" (%"PRId64")\n", data_length, data_length);
  buffer_add_string(b, tmp);

  /* Null terminate the buffer. */
  buffer_add_int8(b, 0);

  return buffer_create_string_and_destroy(b, out_length);
}
Example #11
0
//---------------------------------------------------------------------------
int enviar_infoMap_job(int socket_job,t_map_dest* map_dest){
	int result = 1;

	t_buffer* map_to_Nodo_buff;
	map_to_Nodo_buff = buffer_create_with_protocol(EXECUTE_MAP);


	buffer_add_int(map_to_Nodo_buff, map_dest->id_nodo);
	buffer_add_int(map_to_Nodo_buff, map_dest->block);
	buffer_add_string(map_to_Nodo_buff, map_dest->temp_file_name);
	result = send_buffer_and_destroy(socket_job, map_to_Nodo_buff);

	result = (result > 0) ? send_entire_file_by_parts(socket_job, conf->path_map, MAX_PART_SIZE) : result;


	if(result<= 0) {
		log_error(paranoid_log, "No se pudo enviar Instrucciones de Map");
	} else {
		log_info(paranoid_log, "Se envio correctamente Instrucciones de Map");
	}

	return result;
}
Example #12
0
static uint8_t *encode_cstr(uint8_t *data, uint64_t data_length, uint64_t *out_length)
{
  int i;
  buffer_t *b = buffer_create(BO_HOST);
  char tmp[16];

  for(i = 0; i < data_length; i++)
  {
    if(isalnum(data[i]))
    {
      /* Add letters/numbers as-is. */
      buffer_add_int8(b, data[i]);
    }
    else
    {
      /* Encode all other characters as "\xNN". */
      sprintf(tmp, "\\x%02x", data[i]);
      buffer_add_string(b, tmp);
    }
  }

  return buffer_create_string_and_destroy(b, out_length);
}
Example #13
0
//---------------------------------------------------------------------------
void hilo_reduce_job(t_reduce_dest* reduce_dest) {

	int result = 1;
	uint32_t answer_reduce = 0;

	mostrar_reduce_dest(reduce_dest);

	int _isNodoHost(t_reduce_nodo_dest* nodo) {
		return reduce_dest->id_nodo_host == nodo->id_nodo;
	}
	t_reduce_nodo_dest* nodo_host = list_remove_by_condition(reduce_dest->list_nodos, (void *)_isNodoHost);

	char *ip_nodo = from_int_to_inet_addr(nodo_host->ip_nodo);
	int socket_nodo = solicitarConexionConNodo(ip_nodo, nodo_host->puerto_nodo, nodo_host->id_nodo);

	if(socket_nodo != 1) {
		result = enviar_infoReduce_job(socket_nodo, reduce_dest, nodo_host);
		result = (result > 0) ? receive_answer_reduce(socket_nodo, &answer_reduce) : result;
	} else {
		answer_reduce = INCORRECT_NODO;
	}

	if(result <= 0) {
		answer_reduce = REDUCE_NOT_OK;
	}
	t_buffer* reduce_result_buff;

	switch(answer_reduce) {

		case REDUCE_OK: case REDUCE_NOT_OK:
			reduce_result_buff = buffer_create_with_protocol(answer_reduce);
			if(reduce_dest->prot == ORDER_PARTIAL_REDUCE) {
				buffer_add_int(reduce_result_buff, reduce_dest->id_nodo_host);
			}
			break;

		case INCORRECT_NODO:
			reduce_result_buff = buffer_create_with_protocol(NODO_NOT_FOUND);
			if(reduce_dest->prot == ORDER_REDUCE) {
				buffer_add_int(reduce_result_buff, 1);
				buffer_add_int(reduce_result_buff, nodo_host->id_nodo);
			}
			break;

		case NODO_NOT_FOUND:
			reduce_result_buff = buffer_create_with_protocol(NODO_NOT_FOUND);
			if(reduce_dest->prot == ORDER_REDUCE) {
				uint32_t i,amount_nodes = 0;
				result = receive_int_in_order(socket_nodo, &amount_nodes);
				buffer_add_int(reduce_result_buff, amount_nodes);

				for(i=0;(i<amount_nodes) && (result > 0); i++) {
					uint32_t id_nodo = 0;
					result = receive_int_in_order(socket_nodo, &id_nodo);
					buffer_add_int(reduce_result_buff, id_nodo);
				}

				if(result <= 0) {
					buffer_destroy(reduce_result_buff);
					reduce_result_buff = buffer_create_with_protocol(REDUCE_NOT_OK);
				}
			}
			break;

		case TEMP_NOT_FOUND:
			reduce_result_buff = buffer_create_with_protocol(TEMP_NOT_FOUND);
			uint32_t i,amount_temps = 0;
			result = receive_int_in_order(socket_nodo, &amount_temps);
			buffer_add_int(reduce_result_buff, amount_temps);
			for(i=0;(i<amount_temps) && (result > 0); i++) {
				uint32_t id_nodo = 0;
				result = receive_int_in_order(socket_nodo, &id_nodo);
				if(reduce_dest->prot == ORDER_REDUCE) {
					buffer_add_int(reduce_result_buff, id_nodo);
				}
				char* path = NULL;
				result = (result > 0) ? receive_dinamic_array_in_order(socket_nodo, (void **) &path) : result;
				if(path != NULL) {
					buffer_add_string(reduce_result_buff, path);
					free(path);
				}
			}

			if(result <= 0) {
				buffer_destroy(reduce_result_buff);
				reduce_result_buff = buffer_create_with_protocol(REDUCE_NOT_OK);
			}
			break;

		default:
			reduce_result_buff = buffer_create_with_protocol(REDUCE_NOT_OK);
			break;


	}

	if((socket_nodo != -1) && (result > 0)) {
		close(socket_nodo);
	}

	pthread_mutex_lock(&conex_marta_ready);
	result = (result > 0) ? send_buffer_and_destroy(socket_marta, reduce_result_buff) : result;
	pthread_mutex_unlock(&conex_marta_ready);


	free(ip_nodo);
	free_reduce_nodo_dest(nodo_host);
	free_reduce_dest(reduce_dest);
}
Example #14
0
void dump_dynamic_save(char *outputpath, struct dynamic_store *store)
{
	int i;
	int sub = TRUE;
	char temp[200];
	struct buffer buf;
	buffer_init(&buf);

	if (get_dump_status(dump_dynamic) == TRUE) {

		if (get_dump_status(dump_norm_time_to_one) == TRUE) {
			buf.norm_x_axis = TRUE;
		}

		if (get_dump_status(dump_norm_y_axis) == TRUE) {
			buf.norm_y_axis = TRUE;
		}

		char out_dir[1000];
		sprintf(out_dir, "%s/dynamic/", outputpath);
		struct stat st = { 0 };

		if (stat(out_dir, &st) == -1) {
			mkdir(out_dir, 0700);
		}

		char outpath[200];

		sprintf(outpath, "%s%s", out_dir, "dynamic_jn_mid.dat");
		inter_save(&(store->jnout_mid), outpath);

		struct istruct one;
		inter_copy(&one, &(store->jnout_mid), TRUE);
		inter_deriv(&one, &(store->jnout_mid));
		sprintf(outpath, "%s%s", out_dir, "dynamic_djn.dat");
		inter_save(&one, outpath);
		inter_free(&one);

		sprintf(outpath, "%s%s", out_dir, "dynamic_jp_mid.dat");
		inter_save(&(store->jpout_mid), outpath);

		inter_copy(&one, &(store->jpout_mid), TRUE);
		inter_deriv(&one, &(store->jpout_mid));
		sprintf(outpath, "%s%s", out_dir, "dynamic_djp.dat");
		inter_save(&one, outpath);
		inter_free(&one);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Hole drift plus diffusion current");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Hole current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);

		for (i = 0; i < (store->dynamic_jp_drift).len; i++) {
			sprintf(temp, "%e %e\n", (store->dynamic_jp_drift).x[i],
				(store->dynamic_jp_drift).data[i] +
				(store->dynamic_jp_diffusion).data[i]);
			buffer_add_string(&buf, temp);
		}
		buffer_dump_path(out_dir, "dynamic_jp_drift_plus_diffusion.dat",
				 &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Electron drift plus diffusion current");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Hole current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		for (i = 0; i < (store->dynamic_jn_drift).len; i++) {
			sprintf(temp, "%e %e\n", (store->dynamic_jn_drift).x[i],
				(store->dynamic_jn_drift).data[i] +
				(store->dynamic_jn_diffusion).data[i]);
			buffer_add_string(&buf, temp);
		}
		buffer_dump_path(out_dir, "dynamic_jn_drift_plus_diffusion.dat",
				 &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Current density at contacts");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		if (sub == TRUE) {
			inter_sub_double(&(store->jout), (store->jout).data[0]);
			inter_mul(&(store->jout), -1.0);
		}
		buffer_add_xy_data(&buf, (store->jout).x, (store->jout).data,
				   (store->jout).len);
		buffer_dump_path(out_dir, "dynamic_j.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Change in charge distribution");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "percent");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$\\%$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->charge_change).x,
				   (store->charge_change).data,
				   (store->charge_change).len);
		buffer_dump_path(out_dir, "dynamic_charge_change.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Drift current");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Electron current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_jn_drift).x,
				   (store->dynamic_jn_drift).data,
				   (store->dynamic_jn_drift).len);
		buffer_dump_path(out_dir, "dynamic_jn_drift.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Diffusion current");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Electron current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_jn_diffusion).x,
				   (store->dynamic_jn_diffusion).data,
				   (store->dynamic_jn_diffusion).len);
		buffer_dump_path(out_dir, "dynamic_jn_diffusion.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Drift current");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Hole current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_jp_drift).x,
				   (store->dynamic_jp_drift).data,
				   (store->dynamic_jp_drift).len);
		buffer_dump_path(out_dir, "dynamic_jp_drift.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Diffusion current");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Hole current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_jp_diffusion).x,
				   (store->dynamic_jp_diffusion).data,
				   (store->dynamic_jp_diffusion).len);
		buffer_dump_path(out_dir, "dynamic_jp_diffusion.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Jn contacts");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Electron current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_jn).x,
				   (store->dynamic_jn).data,
				   (store->dynamic_jn).len);
		buffer_dump_path(out_dir, "dynamic_jn_contacts.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Jp contacts");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Hole current density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$A m^{-2}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_jp).x,
				   (store->dynamic_jp).data,
				   (store->dynamic_jp).len);
		buffer_dump_path(out_dir, "dynamic_jp_contacts.dat", &buf);
		buffer_free(&buf);

		sprintf(outpath, "%s%s", out_dir, "dynamic_jn_avg.dat");
		inter_save(&(store->jn_avg), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_jp_avg.dat");
		inter_save(&(store->jp_avg), outpath);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "External Current");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Current");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$Amps$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->iout).x, (store->iout).data,
				   (store->iout).len);
		buffer_dump_path(out_dir, "dynamic_i.dat", &buf);
		buffer_free(&buf);

		sprintf(outpath, "%s%s", out_dir, "dynamic_i_left.dat");
		inter_save(&(store->iout_left), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_i_right.dat");
		inter_save(&(store->iout_right), outpath);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Free carrier generation rate");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Generation rate");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->gexout).x,
				   (store->gexout).data, (store->gexout).len);
		buffer_dump_path(out_dir, "dynamic_gex.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Dynamic quantum efficency");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Percent");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$\%$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_qe).x,
				   (store->dynamic_qe).data,
				   (store->dynamic_qe).len);
		buffer_dump_path(out_dir, "dynamic_qe.dat", &buf);
		buffer_free(&buf);

		double sum = inter_intergrate(&(store->nfree_to_ptrap));
		FILE *out = fopen("dynamic_Rn_int.dat", "w");
		fprintf(out, "%le", sum);
		fclose(out);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Free hole recombination");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Recombination");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->pfree_to_ntrap).x,
				   (store->pfree_to_ntrap).data,
				   (store->pfree_to_ntrap).len);
		buffer_dump_path(out_dir, "dynamic_pf_to_nt.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Free electron recombination");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Recombination");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->nfree_to_ptrap).x,
				   (store->nfree_to_ptrap).data,
				   (store->nfree_to_ptrap).len);
		buffer_dump_path(out_dir, "dynamic_nf_to_pt.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Free electron loss - time");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Free electron loss");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->Rnout).x, (store->Rnout).data,
				   (store->Rnout).len);
		buffer_dump_path(out_dir, "dynamic_Rn.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Free hole loss - time");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Free hole loss");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->Rpout).x, (store->Rpout).data,
				   (store->Rpout).len);
		buffer_dump_path(out_dir, "dynamic_Rp.dat", &buf);
		buffer_free(&buf);

		sum = inter_intergrate(&(store->pfree_to_ntrap));
		out = fopen("dynamic_Rp_int.dat", "w");
		fprintf(out, "%le", sum);
		fclose(out);

		inter_make_cumulative(&(store->nfree_to_ptrap));
		//inter_div_double(&nfree_to_ptrap,in->stark_den);
		sprintf(outpath, "%s%s", out_dir, "dynamic_Rn_cumulative.dat");
		inter_save(&(store->nfree_to_ptrap), outpath);

		inter_make_cumulative(&(store->pfree_to_ntrap));
		//inter_div_double(&pfree_to_ntrap,in->stark_den);
		sprintf(outpath, "%s%s", out_dir, "dynamic_Rp_cumulative.dat");
		inter_save(&(store->pfree_to_ntrap), outpath);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Electron relaxation");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Relaxation");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->nrelax_out).x,
				   (store->nrelax_out).data,
				   (store->nrelax_out).len);
		buffer_dump_path(out_dir, "dynamic_nrelax.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "Hole relaxation");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Relaxation");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "$m^{-3}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->prelax_out).x,
				   (store->prelax_out).data,
				   (store->prelax_out).len);
		buffer_dump_path(out_dir, "dynamic_prelax.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Trapped electron density");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Electron density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->ntrap).x, (store->ntrap).data,
				   (store->ntrap).len);
		buffer_dump_path(out_dir, "dynamic_nt.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Trapped hole density");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Hole density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->ptrap).x, (store->ptrap).data,
				   (store->ptrap).len);
		buffer_dump_path(out_dir, "dynamic_pt.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Free electron density");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Electron density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->nfree).x, (store->nfree).data,
				   (store->nfree).len);
		buffer_dump_path(out_dir, "dynamic_nf.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Free hole density");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Hole density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->pfree).x, (store->pfree).data,
				   (store->pfree).len);
		buffer_dump_path(out_dir, "dynamic_pf.dat", &buf);
		buffer_free(&buf);

		sprintf(outpath, "%s%s", out_dir, "dynamic_nfree_delta.dat");
		inter_save(&(store->nfree_delta_out), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_pfree_delta.dat");
		inter_save(&(store->pfree_delta_out), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_ntrap_delta.dat");
		inter_save(&(store->ntrap_delta_out), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_ptrap_delta.dat");
		inter_save(&(store->ptrap_delta_out), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_filledn.dat");
		inter_save(&(store->tpc_filledn), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_Rn-p.dat");
		inter_save(&(store->Rnpout), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_filledp.dat");
		inter_save(&(store->tpc_filledp), outpath);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Electron mobility");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Mobility");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{2}V^{-1}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->tpc_mue).x,
				   (store->tpc_mue).data, (store->tpc_mue).len);
		buffer_dump_path(out_dir, "dynamic_mue.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Hole mobility");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Mobility");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{2}V^{-1}s^{-1}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->tpc_muh).x,
				   (store->tpc_muh).data, (store->tpc_muh).len);
		buffer_dump_path(out_dir, "dynamic_muh.dat", &buf);
		buffer_free(&buf);

		sprintf(outpath, "%s%s", out_dir, "dynamic_mu_avg.dat");
		inter_save(&(store->tpc_mu_avg), outpath);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Total electron density");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Electron density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->only_n).x,
				   (store->only_n).data, (store->only_n).len);
		buffer_dump_path(out_dir, "dynamic_n.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Total hole density");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Hole density");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$m^{-3}$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->only_p).x,
				   (store->only_p).data, (store->only_p).len);
		buffer_dump_path(out_dir, "dynamic_p.dat", &buf);
		buffer_free(&buf);

		//inter_sub_double(&dynamic_np,dynamic_np.data[0]);
		sprintf(outpath, "%s%s", out_dir, "dynamic_np.dat");
		inter_save(&(store->dynamic_np), outpath);

		inter_norm(&(store->dynamic_np), 1.0);
		sprintf(outpath, "%s%s", out_dir, "dynamic_np_norm.dat");
		inter_save(&(store->dynamic_np), outpath);

		sprintf(outpath, "%s%s", out_dir, "dynamic_E_field.dat");
		inter_div_double(&(store->E_field), (store->E_field).data[0]);
		inter_save(&(store->E_field), outpath);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1e6;
		strcpy(buf.title, "Voltage applied to diode");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "Voltage");
		strcpy(buf.x_units, "$\\mu s$");
		strcpy(buf.y_units, "$V$");
		buf.logscale_x = 0;
		buf.logscale_y = 0;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_Vapplied).x,
				   (store->dynamic_Vapplied).data,
				   (store->dynamic_Vapplied).len);
		buffer_dump_path(out_dir, "dynamic_Vapplied.dat", &buf);
		buffer_free(&buf);

		sprintf(outpath, "%s%s", out_dir, "dynamic_charge_tot.dat");
		inter_sub_double(&(store->dynamic_charge_tot),
				 (store->dynamic_charge_tot).data[0]);
		inter_save(&(store->dynamic_charge_tot), outpath);

		inter_chop(&(store->dynamic_pl), 1.0e-9, 1.0);
		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "PL intensity");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "PL Intensity");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "au");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_pl).x,
				   (store->dynamic_pl).data,
				   (store->dynamic_pl).len);
		buffer_dump_path(out_dir, "dynamic_pl.dat", &buf);
		buffer_free(&buf);

		double max = inter_get_max(&(store->dynamic_pl));
		inter_div_double(&(store->dynamic_pl), max);
		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "PL intensity normalized");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "PL Intensity");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "au");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->dynamic_pl).x,
				   (store->dynamic_pl).data,
				   (store->dynamic_pl).len);
		buffer_dump_path(out_dir, "dynamic_pl_norm.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. srh_n_r1");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "srh_n_r1");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "m^{-3} s^{-1}");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->srh_n_r1).x,
				   (store->srh_n_r1).data,
				   (store->srh_n_r1).len);
		buffer_dump_path(out_dir, "dynamic_srh_n_r1.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. srh_n_r2");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "srh_n_r2");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "m^{-3}s^{-1}");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->srh_n_r2).x,
				   (store->srh_n_r2).data,
				   (store->srh_n_r2).len);
		buffer_dump_path(out_dir, "dynamic_srh_n_r2.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. srh_n_r3");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "srh_n_r3");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "m^{-3}s^{-1}");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->srh_n_r3).x,
				   (store->srh_n_r3).data,
				   (store->srh_n_r3).len);
		buffer_dump_path(out_dir, "dynamic_srh_n_r3.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. srh_n_r4");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "srh_n_r4");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "m^{-3}s^{-1}");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->srh_n_r4).x,
				   (store->srh_n_r4).data,
				   (store->srh_n_r4).len);
		buffer_dump_path(out_dir, "dynamic_srh_n_r4.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. srh_p_r1");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "srh_p_r1");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "m^{-3}s^{-1}");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->srh_p_r1).x,
				   (store->srh_p_r1).data,
				   (store->srh_p_r1).len);
		buffer_dump_path(out_dir, "dynamic_srh_p_r1.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. srh_p_r2");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "srh_p_r2");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "m^{-3}s^{-1}");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->srh_p_r2).x,
				   (store->srh_p_r2).data,
				   (store->srh_p_r2).len);
		buffer_dump_path(out_dir, "dynamic_srh_p_r2.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. srh_p_r3");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "srh_p_r3");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "m^{-3}s^{-1}");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->srh_p_r3).x,
				   (store->srh_p_r3).data,
				   (store->srh_p_r3).len);
		buffer_dump_path(out_dir, "dynamic_srh_p_r3.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. srh_p_r4");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "srh_p_r4");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "m^{-3}s^{-1}");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->srh_p_r4).x,
				   (store->srh_p_r4).data,
				   (store->srh_p_r4).len);
		buffer_dump_path(out_dir, "dynamic_srh_p_r4.dat", &buf);
		buffer_free(&buf);

		buffer_malloc(&buf);
		buf.y_mul = 1.0;
		buf.x_mul = 1.0;
		strcpy(buf.title, "time v.s. band bend (percent)");
		strcpy(buf.type, "xy");
		strcpy(buf.x_label, "Time");
		strcpy(buf.y_label, "band bend");
		strcpy(buf.x_units, "s");
		strcpy(buf.y_units, "percent");
		buf.logscale_x = 1;
		buf.logscale_y = 1;
		buffer_add_info(&buf);
		buffer_add_xy_data(&buf, (store->band_bend).x,
				   (store->band_bend).data,
				   (store->band_bend).len);
		buffer_dump_path(out_dir, "dynamic_band_bend.dat", &buf);
		buffer_free(&buf);
	}

}
Example #15
0
void dump_device_map(char* out_dir,struct device *in)
{
struct buffer buf;
char name[200];
char temp[1000];
int i;
int band;
buffer_init(&buf);


buffer_malloc(&buf);
join_path(2,name,out_dir,"nt_map.dat");


buf.y_mul=1.0;
buf.x_mul=1e9;
strcpy(buf.title,"Charge carrier density - position");
strcpy(buf.type,"xy");
strcpy(buf.x_label,"Position");
strcpy(buf.y_label,"Carrier density");
strcpy(buf.x_units,"nm");
strcpy(buf.y_units,"m^{-3} eV^{-1}");
buf.logscale_x=0;
buf.logscale_y=0;
buffer_add_info(&buf);
for (i=0;i<in->ymeshpoints;i++)
{
	for (band=0;band<in->srh_bands;band++)
	{
		sprintf(temp,"%Le %Le %Le\n",in->ymesh[i],in->Ec[0][0][i]+dos_get_band_energy_n(in,band,in->imat[0][0][i]),in->nt[0][0][i][band]);
		buffer_add_string(&buf,temp);
	}
}
buffer_dump(name,&buf);
buffer_free(&buf);


buffer_malloc(&buf);

join_path(2,name,out_dir,"nt_map.dat");
buf.y_mul=1.0;
buf.x_mul=1e9;
strcpy(buf.title,"Charge carrier density - position");
strcpy(buf.type,"xy");
strcpy(buf.x_label,"Position");
strcpy(buf.y_label,"Carrier density");
strcpy(buf.x_units,"nm");
strcpy(buf.y_units,"m^{-3} eV^{-1}");
buf.logscale_x=0;
buf.logscale_y=0;
buffer_add_info(&buf);
for (i=0;i<in->ymeshpoints;i++)
{
	for (band=0;band<in->srh_bands;band++)
	{
		sprintf(temp,"%Le %Le %Le\n",in->ymesh[i],in->Ev[0][0][i]-dos_get_band_energy_p(in,band,in->imat[0][0][i]),in->pt[0][0][i][band]);
		buffer_add_string(&buf,temp);
	}
}
buffer_dump(name,&buf);
buffer_free(&buf);

}
Example #16
0
int rrdc_update (const char *filename, int values_num, /* {{{ */
		const char * const *values)
{
  char buffer[4096];
  char *buffer_ptr;
  size_t buffer_free;
  size_t buffer_size;
  rrdc_response_t *res;
  int status;
  int i;
  char file_path[PATH_MAX];

  memset (buffer, 0, sizeof (buffer));
  buffer_ptr = &buffer[0];
  buffer_free = sizeof (buffer);

  status = buffer_add_string ("update", &buffer_ptr, &buffer_free);
  if (status != 0)
    return (ENOBUFS);

  pthread_mutex_lock (&lock);
  filename = get_path (filename, file_path);
  if (filename == NULL)
  {
    pthread_mutex_unlock (&lock);
    return (-1);
  }

  status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
  if (status != 0)
  {
    pthread_mutex_unlock (&lock);
    return (ENOBUFS);
  }

  for (i = 0; i < values_num; i++)
  {
    status = buffer_add_value (values[i], &buffer_ptr, &buffer_free);
    if (status != 0)
    {
      pthread_mutex_unlock (&lock);
      return (ENOBUFS);
    }
  }

  assert (buffer_free < sizeof (buffer));
  buffer_size = sizeof (buffer) - buffer_free;
  assert (buffer[buffer_size - 1] == ' ');
  buffer[buffer_size - 1] = '\n';

  res = NULL;
  status = request (buffer, buffer_size, &res);
  pthread_mutex_unlock (&lock);

  if (status != 0)
    return (status);

  status = res->status;
  response_free (res);

  return (status);
} /* }}} int rrdc_update */