示例#1
0
 bool FeatureCoordinates::com_warp_c() const{
   if(!valid_warp_c_){
     if(valid_warp_nor_ && com_c() && com_nor()){
       matrix2dTemp_ = get_J();
       warp_c_ = (matrix2dTemp_*warp_nor_).cast<float>();
       valid_warp_c_ = true;
     }
   }
   return valid_warp_c_;
 }
示例#2
0
double get_equiv_J(struct device *in)
{
	double J = 0.0;
	J = get_J(in);
	if (in->lr_pcontact == RIGHT)
		J *= -1.0;
	J += in->Vapplied / in->Rshunt / in->area;
//printf("%e %e %e\n",(in->xlen*in->zlen),in->Rshunt,in->area);
	return J;
}
示例#3
0
 bool FeatureCoordinates::com_warp_nor() const{
   if(!valid_warp_nor_){
     if(valid_warp_c_ && com_c() && com_nor()){
       matrix2dTemp_ = get_J();
       fullPivLU2d_.compute(matrix2dTemp_);
       if(fullPivLU2d_.rank() == 2){
         warp_nor_ = fullPivLU2d_.inverse()*warp_c_.cast<double>();
         valid_warp_nor_ = true;
       }
     }
   }
   return valid_warp_nor_;
 }
示例#4
0
void sim_pulse(struct device *in)
{
	struct buffer buf;
	buffer_init(&buf);

	struct dynamic_store store;
	dump_dynamic_init(&store, in);

	struct istruct out_i;
	inter_init(&out_i);

	struct istruct out_v;
	inter_init(&out_v);

	struct istruct out_G;
	inter_init(&out_G);

	struct istruct lost_charge;
	inter_init(&lost_charge);

	char config_file_name[200];

	if (find_config_file
	    (config_file_name, in->inputpath, in->simmode, "pulse") != 0) {
		ewe("%s %s %s\n", _("no pulse config file found"),
		    in->inputpath, in->simmode);
	}

	printf("%s\n", config_file_name);

	pulse_load_config(&pulse_config, in, config_file_name);
	int number = strextract_int(config_file_name);
	ntricks_externv_set_load(pulse_config.pulse_Rload);

	in->go_time = FALSE;

	in->time = 0.0;

	time_init(in);
//time_load_mesh(in,number);

	time_load_mesh(in, number);
//time_mesh_save();
//getchar();
//struct istruct pulseout;
//inter_init(&pulseout);

	int ittr = 0;

	int step = 0;
	in->Psun = time_get_sun();
	light_solve_and_update(in, &(in->mylight), time_get_sun(),
			       time_get_laser());

	double V = 0.0;

	if (pulse_config.pulse_sim_mode == pulse_load) {
		sim_externalv(in, time_get_voltage());
		ntricks_externv_newton(in, time_get_voltage(), FALSE);
	} else if (pulse_config.pulse_sim_mode == pulse_open_circuit) {
		in->Vapplied = in->Vbi;
		pulse_newton_sim_voc(in);
		pulse_newton_sim_voc_fast(in, FALSE);
	} else {
		ewe(_("pulse mode not known\n"));
	}

	device_timestep(in);

	in->go_time = TRUE;

	double extracted_through_contacts = 0.0;
	double i0 = 0;
	carrier_count_reset(in);
	reset_np_save(in);
	do {
		in->Psun = time_get_sun();
		light_solve_and_update(in, &(in->mylight), time_get_sun(),
				       time_get_laser() + time_get_fs_laser());
		dump_dynamic_add_data(&store, in, in->time);

		if (pulse_config.pulse_sim_mode == pulse_load) {
			i0 = ntricks_externv_newton(in, time_get_voltage(),
						    TRUE);
		} else if (pulse_config.pulse_sim_mode == pulse_open_circuit) {
			V = in->Vapplied;
			pulse_newton_sim_voc_fast(in, TRUE);
		} else {
			ewe(_("pulse mode not known\n"));
		}

		if (get_dump_status(dump_print_text) == TRUE) {
			printf_log("%s=%e %s=%d %.1e ", _("pulse time"),
				   in->time, _("step"), step, in->last_error);
			printf_log("Vtot=%lf %s = %e mA (%e A/m^2)\n", V,
				   _("current"), get_I(in) / 1e-3, get_J(in));
		}

		ittr++;

		gui_send_data("pulse");
		dump_write_to_disk(in);

		plot_now(in, "pulse.plot");

		inter_append(&out_i, in->time, i0);
		inter_append(&out_v, in->time, V);
		inter_append(&out_G, in->time, in->Gn[0]);
		inter_append(&lost_charge, in->time,
			     extracted_through_contacts -
			     fabs(get_extracted_n(in) +
				  get_extracted_p(in)) / 2.0);

		device_timestep(in);
		step++;

		if (time_run() == FALSE)
			break;
		//getchar();

	} while (1);

	struct istruct out_flip;

	dump_dynamic_save(in->outputpath, &store);
	dump_dynamic_free(&store);

	buffer_malloc(&buf);
	buf.y_mul = 1e3;
	buf.x_mul = 1e6;
	strcpy(buf.title, _("Time - current"));
	strcpy(buf.type, _("xy"));
	strcpy(buf.x_label, _("Time"));
	strcpy(buf.y_label, _("Current"));
	strcpy(buf.x_units, _("us"));
	strcpy(buf.y_units, _("m"));
	buf.logscale_x = 0;
	buf.logscale_y = 0;
	buffer_add_info(&buf);
	buffer_add_xy_data(&buf, out_i.x, out_i.data, out_i.len);
	buffer_dump_path(in->outputpath, "pulse_i.dat", &buf);
	buffer_free(&buf);

	inter_copy(&out_flip, &out_i, TRUE);
	inter_mul(&out_flip, -1.0);

	buffer_malloc(&buf);
	buf.y_mul = 1e3;
	buf.x_mul = 1e6;
	strcpy(buf.title, _("Time - -current"));
	strcpy(buf.type, _("xy"));
	strcpy(buf.x_label, _("Time"));
	strcpy(buf.y_label, _("-Current"));
	strcpy(buf.x_units, _("us"));
	strcpy(buf.y_units, _("mA"));
	buf.logscale_x = 0;
	buf.logscale_y = 0;
	buffer_add_info(&buf);
	buffer_add_xy_data(&buf, out_flip.x, out_flip.data, out_flip.len);
	buffer_dump_path(in->outputpath, "pulse_i_pos.dat", &buf);
	buffer_free(&buf);

	inter_free(&out_flip);

	buffer_malloc(&buf);
	buf.y_mul = 1.0;
	buf.x_mul = 1e6;
	strcpy(buf.title, _("Time - Voltage"));
	strcpy(buf.type, _("xy"));
	strcpy(buf.x_label, _("Time"));
	strcpy(buf.y_label, _("Volts"));
	strcpy(buf.x_units, _("us"));
	strcpy(buf.y_units, _("Voltage"));
	buf.logscale_x = 0;
	buf.logscale_y = 0;
	buffer_add_info(&buf);
	buffer_add_xy_data(&buf, out_v.x, out_v.data, out_v.len);
	buffer_dump_path(in->outputpath, "pulse_v.dat", &buf);
	buffer_free(&buf);

	buffer_malloc(&buf);
	buf.y_mul = 1.0;
	buf.x_mul = 1e6;
	strcpy(buf.title, _("Time - Photogeneration rate"));
	strcpy(buf.type, _("xy"));
	strcpy(buf.x_label, _("Time"));
	strcpy(buf.y_label, _("Generation rate"));
	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, out_G.x, out_G.data, out_G.len);
	buffer_dump_path(in->outputpath, "pulse_G.dat", &buf);
	buffer_free(&buf);

//sprintf(outpath,"%s%s",in->outputpath,"pulse_lost_charge.dat");
//inter_save(&lost_charge,outpath);

	in->go_time = FALSE;

	inter_free(&out_G);
	inter_free(&out_i);
	inter_free(&out_v);
	time_memory_free();
}