Beispiel #1
0
int
main(int argc, char *argv[])
{
    char opt;
    int ret;
    int option_index;

    while ((opt = getopt_long(argc, argv, "d:f:i:lrs",
                    long_options, &option_index)) >= 0) {
        switch (opt) {
        case 'f':
        case 'd':
        case 'i':
            flow_cmd = opt;
            flow_index = strtoul(optarg, NULL, 0);
            break;

        case 'l':
            list = 1;
            break;

        case 'r':
            rate = 1;
            break;
        case 's':
            stats = 1;
            break;
        case 0:
            parse_long_opts(option_index, optarg);
            break;

        default:
            Usage();
        }
    }

    validate_options();

    ret = flow_table_setup();
    if (ret < 0)
        return ret;

    ret = flow_table_get();
    if (ret < 0)
        return ret;

    if (list)
        flow_list();
    else if (rate)
        flow_rate();
    else if (stats)
        flow_stats();
    else
        flow_validate(flow_index, flow_cmd);

    return 0;
}
Beispiel #2
0
void
flow_setup_writer(FLOW_PARAM
                  unsigned int nsync, unsigned int param[W_IDLE])
{
	unsigned int i;
	F_w_sync = nsync;
	for(i=W_IDLE+1; i-- > 0;) {
		F_w_times[i] = flow_rate(f,param[i]);
	}
}
Beispiel #3
0
void network_generator::network_evolution(const char **file){
	
	long double coolant_flow_rate;
	long double unit_pressure_drop = 100.0;
	
	stringstream ss;
	ss << file[channel_layer+2];
	ss >> coolant_flow_rate;
	
	if(!Is_Meaningful()){
		return ;
	}
	while(1){
		print_network();
		long double total_Q = 0;
		vector <int> network_col(101,0);
		vector < vector <int> > single_network(101,network_col);
        vector < vector < vector <int> > > network(channel_layer,single_network);
        vector <int> channel_info_col(101,-1);
        vector < vector <int> > single_channel_info(101,channel_info_col);
		vector < vector < vector <int> > > channel_info(channel_layer,single_channel_info);
		vector <long double> flowrate_col(101,0);
		vector < vector <long double> > single_flow_rate(101,flowrate_col);
		vector < vector < vector <long double> > > flow_rate(channel_layer,single_flow_rate);
		vector < vector < vector <int> > > direction(channel_layer,single_network);
		vector < matrix > matrix_a(channel_layer);
		vector < vector <node> > tempnode(channel_layer);
		vector < vector <edge_info> > edges(channel_layer);
		for (int i = 0; i < channel_layer; i++) {
			network_graph( &liquid_network[i], &tempnode[i], &edges[i]);
			cout << "network_graph done!" << endl;
			matrix_a[i].get_num_channel(&tempnode[i], &edges[i]);
			cout << "get_num_channel done!" << endl;
            matrix_a[i].initial_direction(&tempnode[i], &edges[i]);
            cout << "initial_direction done!" << endl;
            matrix_a[i].write_spice_input(&i, &tempnode[i],unit_pressure_drop);
            cout << "write_spice_input done!" << endl;
            string spice_sim = "hspice spice_";
			spice_sim += i + 48;
			spice_sim += ".txt";
			spice_sim += " > test_";
			spice_sim += i + 48;
			spice_sim += ".txt";
			cout << spice_sim << endl;
			system(spice_sim.c_str());
            matrix_a[i].read_spice_result(&i);
            cout << "read_spice_result done!" << endl;
            matrix_a[i].get_inlet_Q(&tempnode[i]);
		}
		for (int i = 0; i < channel_layer; i++) {
			total_Q += matrix_a[i].inlet_Q;
			//cout << i << " " << "total_Q " << total_Q << "\t" ;
		}
		for (int i = 0; i < channel_layer; i++) {
			cout << "\nchannel_layer " << i << endl;
			matrix_a[i].get_pressure_drop(chip.width, chip.height, chip.length, coolant_flow_rate, unit_pressure_drop, total_Q);
			matrix_a[i].fill_flow_rate(&tempnode[i] ,&edges[i],&flow_rate[i],&channel_info[i]);
			matrix_a[i].fill_direction(&tempnode[i] ,&edges[i],&direction[i]);
			matrix_a[i].write_output(&i,&liquid_network[i], &tempnode[i],&flow_rate[i],&direction[i],&channel_info[i]);
		}
		
		//cout << "file done !" << endl;
		vector < RTree<int, int, 2, float>* > edge_rtree(channel_layer);
		for( int i=0;i<channel_layer;i++ ){
			edge_rtree[i] = new RTree<int, int, 2, float>;
			int minp[2], maxp[2];
			for( int j=0;j<edges[i].size();j++ ){
				minp[0] = min(tempnode[i][edges[i][j].nodes.first].coordinate.first, tempnode[i][edges[i][j].nodes.second].coordinate.first);
				minp[1] = min(tempnode[i][edges[i][j].nodes.first].coordinate.second, tempnode[i][edges[i][j].nodes.second].coordinate.second);
				maxp[0] = max(tempnode[i][edges[i][j].nodes.first].coordinate.first, tempnode[i][edges[i][j].nodes.second].coordinate.first);
				maxp[1] = max(tempnode[i][edges[i][j].nodes.first].coordinate.second, tempnode[i][edges[i][j].nodes.second].coordinate.second);
				if(edges[i][j].HV == 'H'){
					minp[0] += 1;
					maxp[0] -= 1;
					/*cout << tempnode[i][edges[i][j].nodes.first].coordinate.first << " " << tempnode[i][edges[i][j].nodes.second].coordinate.first << endl;
					cout << tempnode[i][edges[i][j].nodes.first].coordinate.second << " " << tempnode[i][edges[i][j].nodes.second].coordinate.second << endl;
					cout << minp[0] << " " << maxp[0] << endl;
					cout << minp[1] << " " << maxp[1] << endl;*/
					//getchar();
				}
				else if(edges[i][j].HV == 'V'){
					minp[1] += 1;
					maxp[1] -= 1;
				}
				if(edges[i][j].HV != 'N'){
					edge_rtree[i]->Insert(minp, maxp, j);
				}
			}
		}
		//cout << "Rtree done !" << endl;
		/*int minp[2], maxp[2];
		minp[0] = 17;
		minp[1] = 0;
		maxp[0] = 17;
		maxp[1] = 4;
		vector <int> edge_list;
		for( int i=0;i<channel_layer;i++ ){
			edge_list.clear();
			edge_rtree[i]->Search(minp, maxp, &edge_list);
			for( int k=0;k<edge_list.size();k++ ){
				cout << tempnode[i][edges[i][edge_list[k]].nodes.first].coordinate.first << " " << tempnode[i][edges[i][edge_list[k]].nodes.first].coordinate.second << endl;
				cout << tempnode[i][edges[i][edge_list[k]].nodes.second].coordinate.first << " " << tempnode[i][edges[i][edge_list[k]].nodes.second].coordinate.second << endl;
			}
			cout << edge_list.size() << endl;
		}
		getchar();*/
		
		chdir("3d-ice/bin/");
		string simulator = "./3D-ICE-Emulator test_case_0";
		simulator += chip.case_num + 48;
		simulator += ".stk";
		for( int i=0;i<channel_layer;i++ ){
			simulator += " ../../network_";
			simulator += i+48;
			simulator += " ../../flowrate_";
			simulator += i+48;
			simulator += " ../../direction_";
			simulator += i+48;
		}
		//cout << simulator << endl;
		system(simulator.c_str());
		//getchar();
		
		chdir("../../");
		ifstream *fin = new ifstream[channel_layer+1];
		vector < vector < vector <double> > > T_map;
		double T_max = 0, T_min = 1<<30;
		pair<int, int> target;
		for( int i=0;i<channel_layer+1;i++ ){
			string file_location = "3d-ice/bin/testcase_0";
			vector < vector <double> > temp_T_map(101, vector <double>(101));
			file_location += chip.case_num+48;
			file_location += "/output_";
			file_location += i+48;
			file_location += ".txt";
			cout << file_location << endl;
			
			fin[i].open(file_location.c_str());
			if(fin[i].eof()){
				cout << "error tmap !" << endl;
				return ;
			}
			else{
				for( int k=0;k<temp_T_map.size();k++ ){
					for( int j=0;j<temp_T_map[k].size();j++ ){
						fin[i] >> temp_T_map[k][j];
						if(T_max < temp_T_map[k][j]){
							T_max = temp_T_map[k][j];
							target.first = j;
							target.second = k;
						}
						if(T_min > temp_T_map[k][j]){
							T_min = temp_T_map[k][j];
						}
					}
				}
			}
			fin[i].close();
			T_map.push_back(temp_T_map);
			print_heat_color_picture(&temp_T_map, i);
		}
		if(T_max - T_min >= chip.T_gredient){
			cout << "T_gredient fail !!!" << endl;
			cout << "T_gredient : " << chip.T_gredient << endl;
			cout << "your gragient : " << T_max - T_min << endl;
		}
		if(T_max > chip.T_max+273){
			cout << "T_max fail !!!" << endl;
			cout << "T_max : " << chip.T_max << endl;
			cout << "your T_max : " << T_max << endl;
		}
		cout << "your T_max : " << T_max << endl;
		pout(target);
		cout << endl;
		cout << "sim over !!!!!!!!!!!!!!!!!!" << endl;
		return;
		
		cout << endl;
		cout << T_max << endl;
		if(optimization_move_channel(target, &edge_rtree, &edges, &tempnode)){
			cout << "good" << endl;
		}
		else{
			cout << "bad" << endl;
		}
		getchar();
	}
	
	
}