Beispiel #1
0
FXString FileDlg::getFilename() {
  if (getSelectMode()==SELECTFILE_ANY) {
    FXString fn=FXFileDialog::getFilename();
    if (ReadShortcut(getShell(), fn)) {
      FXFileDialog::setFilename(fn);
    }
    return FXFileDialog::getFilename();
  } else {
    return filenames ? (*filenames) : FXFileDialog::getFilename();
  }
}
Beispiel #2
0
bool ShortcutList::DeleteShortcut(MenuSpec*spec)
{
    FXHotKey acckey=parseAccel(spec->accel);
    FXAccelTable*table=win->getAccelTable();
    if (!table->hasAccel(acckey)) {
        return true;
    } else {
        if (FXMessageBox::question(getShell(), MBOX_YES_NO, _("Confirm delete"),
                                   _("Are you sure you want to remove this keybinding?")
                                  )==MBOX_CLICKED_YES) {
            table->removeAccel(acckey);
            memset(spec->accel,0,sizeof(spec->accel));
            UpdateListItem(spec);
            return true;
        } else {
            return false;
        }
    }
}
Beispiel #3
0
FXuint FileDlg::execute(FXuint placement) {
  DeleteFilenames();
  FXuint rv=FXFileDialog::execute(placement);
  if (rv) {
    filenames = FXFileDialog::getFilenames();
    own_filenames=true;
    if (filenames) {
      if (getSelectMode()!=SELECTFILE_MULTIPLE) {
        filenames[0]=FXFileDialog::getFilename();
      }
      FixupShortcuts(getShell(), filenames);
      if (FXStat::isDirectory(filenames->text())) {
        setFilename("*");
        filenames->append("\\.");
        setDirectory(filenames->text());
        DeleteFilenames();
        return execute(placement);
      }
    }
  }
  return rv;
}
Beispiel #4
0
// Cleanup; icons must be explicitly deleted
FileSelector::~FileSelector()
{	
	// Write options to the registry
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","name_size",list->getHeaderSize(0));
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","size_size",list->getHeaderSize(1));
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","type_size",list->getHeaderSize(2));
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","ext_size",list->getHeaderSize(3));
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","modd_size",list->getHeaderSize(4));
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","user_size",list->getHeaderSize(5));
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","grou_size",list->getHeaderSize(6));
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","attr_size",list->getHeaderSize(7));
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","listmode",getFileBoxStyle());
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","hiddenfiles",shownHiddenFiles());
	getApp()->reg().writeUnsignedEntry("FILEDIALOG","thumbnails",shownThumbnails());
	getApp()->reg().write();
	
	FXAccelTable *table=getShell()->getAccelTable();
	if(table)
	{
    	table->removeAccel(MKUINT(KEY_BackSpace,0));
    	table->removeAccel(MKUINT(KEY_h,CONTROLMASK));
    	table->removeAccel(MKUINT(KEY_w,CONTROLMASK));
    	table->removeAccel(MKUINT(KEY_a,CONTROLMASK));
    	table->removeAccel(MKUINT(KEY_i,CONTROLMASK));
    }
    delete list;
    delete pathlink;
	delete pathtext;
	delete filename;
	delete filefilter;
	delete readonly;
	delete accept;
	delete cancel;
	delete btnbackhist;
	delete btnforwardhist;
}
Beispiel #5
0
int main() {

    int i, j, tstep;

    time_t t;
    srand((unsigned) time(&t));

    struct timeval startTime, endTime;
    long long time1, time2, totaltime;

    getBasic();
    printf("No. of Particles : %d\nNo. of Particles on shell : %d\nShell Radius : %d \n", npos, nsphere, shell_radius);

    /////START TOTAL_TIME
    //gettimeofday(&startTime, NULL);

    double *pos, *shell, *rad;
    pos = (double *)malloc(sizeof(double)*(npos+nsphere)*3);
    rad = (double *)malloc(sizeof(double)*npos);
    shell = pos + 3*npos;

    setPosRad(pos, rad);
    savePos(pos, rad, 0);
    getShell(shell);

    //printf("here\n");

    //check pos & shell
    //printVectors(pos, npos+nsphere, 3);

    double L = 2*shell_radius;
    int boxdim = shell_radius;
    double cutoff2 = (2 * shell_particle_radius) * (2 * shell_particle_radius);

    int maxnumpairs = 5000000;
    int *pairs = (int *)malloc(sizeof(int)*2*maxnumpairs);
    int *finalPairs = (int *)malloc(sizeof(int)*2*maxnumpairs);
    double *distances2 = (double *)malloc(sizeof(double)*maxnumpairs);
    int numpairs_p;

    double *f;
    f = (double *)malloc(sizeof(double)*3*npos);
    complex *f1, *f2, *f3, *rpy, *lanczos_out;
    f1 = (complex *)malloc(sizeof(complex)*npos);
    f2 = (complex *)malloc(sizeof(complex)*npos);
    f3 = (complex *)malloc(sizeof(complex)*npos);
    rpy = (complex *)malloc(sizeof(complex)*(npos*3));
    lanczos_out = (complex *)malloc(sizeof(complex)*(npos*3));

    double *f_serial;
    f_serial = (double *)malloc(sizeof(double)*3*npos);
    double error1, error2;
    double *standardNormalZ1, *standardNormalZ;
    standardNormalZ = (double *)malloc(sizeof(double)*npos*3);
    standardNormalZ1 = (double *)malloc(sizeof(double)*npos*3);

    lanczos_t *lanczos, *lanczos1;
    lanczos = malloc(sizeof(lanczos));

    int maxiters = 200;
    double *A;
    lanczos1 = malloc(sizeof(lanczos));
    A = (double *)malloc(sizeof(double)*3*3*npos*npos);
    char dir[100] = "outputs/";

    //double *Mf;
    //Mf = (double *)malloc(sizeof(double)*3*npos);

    for(tstep = 0; tstep<tmax; tstep++) {

        printf("time step %d started\n", tstep+1);



        //gettimeofday(&startTime, NULL);
        interactions(npos+nsphere, pos, L, boxdim, cutoff2, distances2, pairs, maxnumpairs, &numpairs_p);
        interactionsFilter(&numpairs_p, pairs, finalPairs, rad, pos);

        printf("beyond interactions\n");
        //printf("Final number of pairs (after filtering) : %d\n", numpairs_p);

        computeForce(f, f1, f2, f3, pos, rad, finalPairs, numpairs_p);
        //gettimeofday(&endTime, NULL);
        //time1 = (endTime.tv_sec-startTime.tv_sec)*1000000 + endTime.tv_usec-startTime.tv_usec;
        //printf("For INTERACTIVE : %ld msec\n", time1/1000);


        if(CHECKCODE) {

            //gettimeofday(&startTime, NULL);
            computeForceSerial(f_serial, pos, rad, shell);
            //gettimeofday(&endTime, NULL);
            //time2 = (endTime.tv_sec-startTime.tv_sec)*1000000 + endTime.tv_usec-startTime.tv_usec;
            //printf("For SERIAL : %ld msec\n", time2/1000);

            //printVectors(f_serial, npos, 3);

            //error1 = relError(f_serial, f, npos, 3);
            //printf("Relative Error in computeForce %lf\n", error1);
            //error2 = maxError(f_serial, f, npos, 3);
            //printf("Max Error in computeForce %lf\n", error2);
        }

        //char dir[100] = "outputs/";
        //printf("Calling computeRPY : \n");
        //gettimeofday(&startTime, NULL);

        computerpy_(&npos, pos, rad, f1, f2, f3, rpy, dir);

        //gettimeofday(&endTime, NULL);
        //time2 = (endTime.tv_sec-startTime.tv_sec)*1000000 + endTime.tv_usec-startTime.tv_usec;
        //printf("For 5 call FMM: %ld \n", time2/1000);

        //gettimeofday(&endTime, NULL);
        //time1 = (endTime.tv_sec-startTime.tv_sec)*1000000 + endTime.tv_usec-startTime.tv_usec;
        //printf("Total Time taken for RPY with FMM: %ld \n", time1/1000);

        //printf("Calling postCorrection : \n");
        //gettimeofday(&startTime, NULL);

        //postCorrection(npos, pos, rad, numpairs_p, finalPairs, f1, f2, f3, rpy);





        getNorm((100000000+(rand()%99999999)), standardNormalZ);
        //getNorm((100000000+(rand()%99999999)), standardNormalZ1);
        //printVectors(standardNormalZ, 3*npos, 1);

        /*
        		if(CHECKCODE){

        			for(i=0;i<npos*3;i++)
        				standardNormalZ1[i] = standardNormalZ[i];
        		}
        */

        //

        if(CHECKCODE) {

            //create_lanczos (&lanczos1, 1, maxiters, npos*3);

            //double *Az;
            //Az = (double *)malloc(sizeof(double)*3*npos);

            //gettimeofday(&startTime, NULL);
            createDiag(A, rad);
            //sqrtMatrix(A, standardNormalZ1);

            //printVectors(A, 3*npos, 3*npos);

            //printVectorsToFile(A, 3*npos);

            mobilityMatrix(A, pos, rad);

            //printVectorsToFile(A, 3*npos);

            //printVectorsToFile(A, npos*3);

            //compute_lanczos(lanczos1, 1e-4, 1, standardNormalZ1, 3*npos,
            //		SERIAL, f1, f2, f3, lanczos_out, pos, rad, numpairs_p, finalPairs, A);

            //printf("Z: \n");
            //printVectors(standardNormalZ1, npos, 3);

            //printVectorsToFile(A, 3*npos);

            multiplyMatrix(A, f_serial);

            //gettimeofday(&endTime, NULL);
            //time1 = (endTime.tv_sec-startTime.tv_sec)*1000000 + endTime.tv_usec-startTime.tv_usec;
            //printf("For SERIAL : %ld msec\n", time1/1000);

            //printf("Mf: \n");
            //printf("M*f : \n");
            //printVectors(A, npos, 3);
            //printf("\n");

            //printf("RPY : \n");
            //printVectorsComplex(rpy, 10, 3);
            //printf("\n");

            //printf("Relative error in RPy and M*f : %lf\n", relErrorRealComplex(A, rpy, npos, 3));
            //printf("Maximum error in Rpy and M*f : %lf\n", maxErrorRealComplex(A, rpy, npos, 3));

        }

        //printf("Adding Random Brownian motion ... \n");

        create_lanczos (&lanczos, 1, maxiters, npos*3);
        compute_lanczos(lanczos, 1e-4, 1, standardNormalZ, 3*npos,
                        FMM, f1, f2, f3, lanczos_out, pos, rad, numpairs_p, finalPairs, A);


        /////////END TOTAL_TIME
        //gettimeofday(&endTime, NULL);
        //totaltime = (endTime.tv_sec-startTime.tv_sec)*1000000 + endTime.tv_usec-startTime.tv_usec;
        //printf("Total time computing 1 time step (%d particles) : %ld msec\n", npos, totaltime/1000);


        //if(CHECKCODE){
        //	printf("Relative Error in brownian : %lf\n", relError(standardNormalZ, standardNormalZ1, npos, 3));
        //}


        updatePos(pos, rpy, standardNormalZ);
        //updatePosSerial(pos, A, standardNormalZ1);
        //printf("new pos: \n");
        //printVectors(pos, npos, 3);
        savePos(pos, rad, tstep+1);

        printf("%d time steps done\n\n", tstep+1);

    }

    //gettimeofday(&endTime, NULL);
    //totaltime = (endTime.tv_sec-startTime.tv_sec)*1000000 + endTime.tv_usec-startTime.tv_usec;
    //printf("Total time computing %d time steps (%d particles) : %ld msec\n", tmax, npos, totaltime/1000);

    return 0;
}
Beispiel #6
0
// File selector object
FileSelector::FileSelector(FXComposite *p,FXObject* tgt,FXSelector sel,FXuint opts,FXint x,FXint y,FXint w,FXint h):
        FXPacker(p,opts,x,y,w,h,0,0,0,0,0,0)
{
	FXAccelTable *table=getShell()->getAccelTable();
    target=tgt;
    message=sel;
    
    // Global container
    FXVerticalFrame* cont=new FXVerticalFrame(this,LAYOUT_FILL_Y|LAYOUT_FILL_X|FRAME_NONE,0,0,0,0, 0,0,0,0, 0,0);

    // Container for the action buttons
    FXHorizontalFrame* buttons=new FXHorizontalFrame(cont,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED,0,0,0,0, 5,5,5,5, 0,0);
    
    // Container for the path linker
    FXHorizontalFrame* pathframe=new FXHorizontalFrame(cont,LAYOUT_FILL_X|FRAME_RAISED,0,0,0,0, 0,0,0,0, 0,0);

	// File list
	FXuint options = _ICONLIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y;

	FXbool thumbnails=getApp()->reg().readUnsignedEntry("FILEDIALOG","thumbnails",FALSE);
    list=new FileList(this,cont,this,ID_FILELIST,thumbnails,options);
    
	// Set list colors and columns size for detailed mode
	list->setTextColor(getApp()->reg().readColorEntry("SETTINGS","listforecolor",FXRGB(0,0,0)));
	list->setBackColor(getApp()->reg().readColorEntry("SETTINGS","listbackcolor",FXRGB(255,255,255)));
	list->setHeaderSize(0,getApp()->reg().readUnsignedEntry("FILEDIALOG","name_size",200));
    list->setHeaderSize(1,getApp()->reg().readUnsignedEntry("FILEDIALOG","size_size",60));
    list->setHeaderSize(2,getApp()->reg().readUnsignedEntry("FILEDIALOG","type_size",100));
    list->setHeaderSize(3,getApp()->reg().readUnsignedEntry("FILEDIALOG","ext_size",100));
    list->setHeaderSize(4,getApp()->reg().readUnsignedEntry("FILEDIALOG","modd_size",150));
    list->setHeaderSize(5,getApp()->reg().readUnsignedEntry("FILEDIALOG","user_size",50));
    list->setHeaderSize(6,getApp()->reg().readUnsignedEntry("FILEDIALOG","grou_size",50));
    list->setHeaderSize(7,getApp()->reg().readUnsignedEntry("FILEDIALOG","attr_size",100));  	
	
	// Set file selector options
	FXbool hiddenfiles=getApp()->reg().readUnsignedEntry("FILEDIALOG","hiddenfiles",FALSE);
	showHiddenFiles(hiddenfiles);

	FXuint listmode=getApp()->reg().readUnsignedEntry("FILEDIALOG","listmode",0);
	setFileBoxStyle(listmode);

    // Entry buttons
    FXMatrix* fields=new FXMatrix(cont,3,MATRIX_BY_COLUMNS|LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X);
    new FXLabel(fields,_("&File Name:"),NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y);
    filename=new FXTextField(fields,25,this,ID_ACCEPT,TEXTFIELD_ENTER_ONLY|LAYOUT_FILL_COLUMN|LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK);
    new FXButton(fields,_("&OK"),NULL,this,ID_ACCEPT,BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X,0,0,0,0,20,20);
    accept=new FXButton(buttons,FXString::null,NULL,NULL,0,LAYOUT_FIX_X|LAYOUT_FIX_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,0,0,0,0, 0,0,0,0);
    new FXLabel(fields,_("File F&ilter:"),NULL,JUSTIFY_LEFT|LAYOUT_CENTER_Y);
    FXHorizontalFrame* filterframe=new FXHorizontalFrame(fields,LAYOUT_FILL_COLUMN|LAYOUT_FILL_X|LAYOUT_FILL_Y);
  	filefilter=new FXComboBox(filterframe,10,this,ID_FILEFILTER,COMBOBOX_STATIC|FRAME_SUNKEN|LAYOUT_FILL_X);
  	filefilter->setNumVisible(4);

    readonly=new FXCheckButton(filterframe,_("Read Only"),NULL,0,ICON_BEFORE_TEXT|JUSTIFY_LEFT|LAYOUT_CENTER_Y);
    cancel=new FXButton(fields,_("&Cancel"),NULL,NULL,0,BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_FILL_X,0,0,0,0,20,20);

    // Action buttons
    FXString key;
	FXHotKey hotkey;
	FXButton *btn;
	FXToggleButton *tglbtn;
	
	new FXFrame(buttons,LAYOUT_FIX_WIDTH,0,0,4,1);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_back","Ctrl-Backspace");
    btn=new FXButton(buttons,TAB+_("Go to previous directory")+PARS(key),dirbackicon,this,ID_DIR_BACK,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	btnbackhist=new FXArrowButton(buttons,this,ID_DIR_BACK_HIST,LAYOUT_FILL_Y|FRAME_RAISED|FRAME_THICK|ARROW_DOWN|ARROW_TOOLBAR);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_forward","Shift-Backspace");
    btn=new FXButton(buttons,TAB+_("Go to next directory")+PARS(key),dirforwardicon,this,ID_DIR_FORWARD,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	btnforwardhist=new FXArrowButton(buttons,this,ID_DIR_FORWARD_HIST,LAYOUT_FILL_Y|FRAME_RAISED|FRAME_THICK|ARROW_DOWN|ARROW_TOOLBAR);
	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_up","Backspace");
    btn=new FXButton(buttons,TAB+_("Go to parent directory")+PARS(key),dirupicon,this,ID_DIR_UP,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

 	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_home","Ctrl-H");
    btn=new FXButton(buttons,TAB+_("Go to home directory")+PARS(key),homeicon,this,ID_HOME,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

 	key=getApp()->reg().readStringEntry("KEYBINDINGS","go_work","Shift-F2");
    btn=new FXButton(buttons,TAB+_("Go to working directory")+PARS(key),workicon,this,ID_WORK,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","new_folder","F7");
    btn=new FXButton(buttons,TAB+_("New folder")+PARS(key),newfoldericon,this,ID_NEWDIR,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","big_icons","F10");
    btn=new FXButton(buttons,TAB+_("Big icon list")+PARS(key),bigiconsicon,list,FileList::ID_SHOW_BIG_ICONS,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","small_icons","F11");
    btn=new FXButton(buttons,TAB+_("Small icon list")+PARS(key),smalliconsicon,list,FileList::ID_SHOW_MINI_ICONS,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","detailed_file_list","F12");
    btn=new FXButton(buttons,TAB+_("Detailed file list")+PARS(key),detailsicon,list,FileList::ID_SHOW_DETAILS,BUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	btn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","hidden_files","Ctrl-F6");
    tglbtn=new FXToggleButton(buttons,TAB+_("Show hidden files")+PARS(key),TAB+_("Hide hidden files")+PARS(key),showhiddenicon,hidehiddenicon,list,FileList::ID_TOGGLE_HIDDEN,TOGGLEBUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	tglbtn->addHotKey(hotkey);

	key=getApp()->reg().readStringEntry("KEYBINDINGS","thumbnails","Ctrl-F7");
    tglbtn=new FXToggleButton(buttons,TAB+_("Show thumbnails")+PARS(key),TAB+_("Hide thumbnails")+PARS(key),showthumbicon,hidethumbicon,list,FileList::ID_TOGGLE_THUMBNAILS,TOGGLEBUTTON_TOOLBAR|FRAME_RAISED,0,0,0,0, 3,3,3,3);
	hotkey=_parseAccel(key);
	tglbtn->addHotKey(hotkey);

	// Path text
	pathtext=new TextLabel(pathframe,0,this,0,LAYOUT_FILL_X|LAYOUT_FILL_Y);
	pathtext->setBackColor(getApp()->getBaseColor());

    // Path linker
    pathlink = new PathLinker(pathframe,list,NULL,LAYOUT_FILL_X);

    readonly->hide();
  	if(table)
	{
 		FXString key;
		FXHotKey hotkey;
		
  		key=getApp()->reg().readStringEntry("KEYBINDINGS","select_all","Ctrl-A");
		hotkey=_parseAccel(key);	
		table->addAccel(hotkey,list,FXSEL(SEL_COMMAND,FileList::ID_SELECT_ALL));
  	
		key=getApp()->reg().readStringEntry("KEYBINDINGS","deselect_all","Ctrl-Z");
		hotkey=_parseAccel(key);	
		table->addAccel(hotkey,list,FXSEL(SEL_COMMAND,FileList::ID_DESELECT_ALL));
	
  		key=getApp()->reg().readStringEntry("KEYBINDINGS","invert_selection","Ctrl-I");
		hotkey=_parseAccel(key);	
		table->addAccel(hotkey,list,FXSEL(SEL_COMMAND,FileList::ID_SELECT_INVERSE));
	
		key=getApp()->reg().readStringEntry("KEYBINDINGS","new_file","F2");
		hotkey=_parseAccel(key);	
		table->addAccel(hotkey,this,FXSEL(SEL_COMMAND,ID_NEWFILE));
    }

    setSelectMode(SELECT_FILE_ANY);                          // For backward compatibility, this HAS to be the default!
    setPatternList(allfiles);
    setDirectory(FXSystem::getCurrentDirectory());           // Update file list
   	pathlink->setPath(FXSystem::getCurrentDirectory());      // Update path linker
   	pathtext->setText(FXSystem::getCurrentDirectory());      // Update path text

    list->setFocus();
    accept->hide();

	// Change default cursor if single click navigation
	if (single_click==SINGLE_CLICK_DIR_FILE)
		list->setDefaultCursor(getApp()->getDefaultCursor(DEF_HAND_CURSOR));
}
Beispiel #7
0
/// PGTOのnormalize
double Fl_Gto::getNormalized(const int s, const int p, const int l, const int m,
                             const int n) const {
  //   std::cout << TlUtils::format("Fl_Gto::getNormalized s=%d, p=%d, l=%d,
  //   m=%d, n=%d) ",
  //                   s, p, l, m, n)
  //        << TlUtils::format("cgto_size = %d, contraction = %d",
  //                   this->cgto.size(),
  //                   static_cast<int>(this->cgto[s].contraction()))
  //        << std::endl;
  assert((0 <= s) && (s < static_cast<int>(this->cgto.size())));
  assert((0 <= p) && (p < static_cast<int>(this->cgto[s].contraction())));
  assert(l >= 0);
  assert(m >= 0);
  assert(n >= 0);

  TlLogging& log = TlLogging::getInstance();

  // chech consistent with shell.
  int maxangular = 0;
  switch (getShell(s)) {
    case 's':
      maxangular = 0;
      break;
    case 'p':
      maxangular = 1;
      break;
    case 'd':
      maxangular = 2;
      break;
    case 'f':
      maxangular = 3;
      break;
    case 'g':
      maxangular = 4;
      break;
    default:
      log.error(
          " *** Fl_Gto::getNormalized() not support over g angular momentum, "
          "sorry.");
      CnErr.abort();
      break;
  }

  if (l + m + n > maxangular) {
    log.error(
        " *** Fl_Gto::getNormalized() illegal angular momentum, inconsistent "
        "with shell.");
    CnErr.abort();
  }

  // calculate normalized factor of pGTO, of which angular part is X^l Y^m Z^n
  // type.
  TlMath Math;
  double pwr = (double)(l + m + n);
  double ans = std::pow(2.0, pwr);
  ans *= std::pow(
      Math.dbfact(2 * l - 1) * Math.dbfact(2 * m - 1) * Math.dbfact(2 * n - 1),
      -1.0 / 2.0);
  ans *= std::pow(2.0 / Math.PI(), 3.0 / 4.0);
  ans *= std::pow(this->getExponent(s, p), (pwr + 3.0 / 2.0) / 2.0);

  return ans;
}
Beispiel #8
0
// normalized factor =========================================================
//
double Fl_Gto::getNormalizedfactor(int s, int l, int m, int n) const {
  TlLogging& log = TlLogging::getInstance();

  // index check for s.
  if (s > this->getNumOfCGTOs() - 1) {
    log.error(" *** Fl_Gto::getNormalizedfactor()");
    log.error(
        " force to load(get) basis data over avairable "
        "maximun(getNumbercgto()), Log of Range.");
    log.error("     this is program error.");
    CnErr.abort();
  }

  // index chech l, m, n.
  if (l < 0 || m < 0 || n < 0) {
    log.error(" *** Fl_Gto::getNormalizedfactor() illegal angular momentum.");
    CnErr.abort();
  }

  // chech consistent with shell.
  int maxangular = 0;
  switch (getShell(s)) {
    case 's':
      maxangular = 0;
      break;
    case 'p':
      maxangular = 1;
      break;
    case 'd':
      maxangular = 2;
      break;
    case 'f':
      maxangular = 3;
      break;
    case 'g':
      maxangular = 4;
      break;
    default:
      log.error(
          " *** Fl_Gto::getNormalizedfactor() not support over g angular "
          "momentum, sorry.");
      CnErr.abort();
      break;
  }

  if (l + m + n > maxangular) {
    log.error(
        " *** Fl_Gto::getNormalizedfactor() illegal angular momentum, "
        "inconsistent with shell.");
    CnErr.abort();
  }

  // calculate normalized factor of CGTO, of which angular part is X^l Y^m Z^n
  // type.
  TlMath Math;
  double pwr = (double)(l + m + n) + 3.0 / 2.0;
  double ans = 0.0;

  const int contractions = this->getContraction(s);
  for (int a = 0; a < contractions; a++) {
    const double coef_a = this->getCoefficient(s, a);
    const double norm_a = this->getNormalized(s, a, l, m, n);
    const double exp_a = this->getExponent(s, a);

    for (int b = 0; b < contractions; b++) {
      const double coef_b = this->getCoefficient(s, b);
      const double norm_b = this->getNormalized(s, b, l, m, n);
      const double exp_b = this->getExponent(s, b);

      double trm = coef_a * coef_b;
      trm *= norm_a * norm_b;
      trm *= std::pow(exp_a + exp_b, -pwr);
      ans += trm;
    }
  }
  ans *=
      Math.dbfact(2 * l - 1) * Math.dbfact(2 * m - 1) * Math.dbfact(2 * n - 1);
  ans *= std::pow(2.0, -(double)(l + m + n));
  ans *= std::pow(Math.PI(), 3.0 / 2.0);
  ans = Math.sqrt(1.0 / ans);

  return ans;
}
Beispiel #9
0
void Fl_Gto::show() const {
  TlLogging& log = TlLogging::getInstance();

  std::stringstream ss;
  int angular;

  ss << "----------------------------------------------------------------------"
        "--\n";
  ss << " numbercgto     : " + TlUtils::xtos(this->getNumOfCGTOs()) + "\n";
  ss << "----------------------------------------------------------------------"
        "--\n";
  for (int i = 0; i < this->getNumOfCGTOs(); i++) {
    ss << " --- " << i << " th CGTO --------------------\n";
    ss << "Snum [" << this->cgto[i].Snum << "]\n";
    ss << "Pnum [" << this->cgto[i].Pnum << "]\n";
    ss << "Dnum [" << this->cgto[i].Dnum << "]\n";
    ss << "basis             [" << cgto[i].basisName << "]\n";
    ss << "atom              [" << cgto[i].atom << "]\n";
    ss << "label             [" << cgto[i].label << "]\n";
    ss << "shellname         [" << cgto[i].shellname << "]\n";
    ss << "shell              " << cgto[i].shell << " \n";

    ss << TlUtils::format("  scale factor     = %18.8lf\n",
                          cgto[i].scalefactor);
    ss << TlUtils::format("  contraction      = %18ld\n",
                          cgto[i].contraction());
    ss << "  <normalizedfactor> ";

    if (getShell(i) == 's') {
      angular = 0;
    } else if (getShell(i) == 'p') {
      angular = 1;
    } else if (getShell(i) == 'd') {
      angular = 2;
    } else if (getShell(i) == 'f') {
      angular = 3;
    } else {
      ss << " *** Fl_Gto::show() not supported such large shell.\n";
      ss << "     +++ calculate in case of l=m=n=0, and continue.\n";
      angular = 0;
    }
    for (int l = 0; l <= angular; l++) {
      for (int m = 0; m <= angular; m++) {
        for (int n = 0; n <= angular; n++) {
          if (l + m + n == angular) {
            ss << TlUtils::format("  (%1ld,%1ld,%1ld) = %18.8lE ", l, m, n,
                                  getNormalizedfactor(i, l, m, n));
          }
        }
      }
    }
    ss << "\n";
    ss << "    // primitive GTO //\n";

    for (int j = 0; j < cgto[i].contraction(); j++) {
      ss << TlUtils::format("      %18.8lE %18.8lE \n",
                            this->cgto[i].pgto[j].exponent,
                            this->cgto[i].pgto[j].coefficient);
      ss << "  <normalized> ";

      if (getShell(i) == 's')
        angular = 0;
      else if (getShell(i) == 'p')
        angular = 1;
      else if (getShell(i) == 'd')
        angular = 2;
      else if (getShell(i) == 'f')
        angular = 3;
      else {
        ss << " *** Fl_Gto::show() not supported such large shell.\n";
        ss << "     +++ calculate in case of l=m=n=0, and continue.\n";
        angular = 0;
      }
      for (int l = 0; l <= angular; l++) {
        for (int m = 0; m <= angular; m++) {
          for (int n = 0; n <= angular; n++) {
            if (l + m + n == angular) {
              ss << TlUtils::format("  (%1ld,%1ld,%1ld) = %18.8lE %18.8lE \n",
                                    l, m, n, getNormalized(i, j, l, m, n),
                                    getCoulombnormalized(i, j, l, m, n));
            }
          }
        }
      }
      ss << "\n";
    }
  }
  ss << " ---------------------------------------------------------------------"
        "---\n";

  log.info(ss.str());
}
Beispiel #10
0
/*
 *----------------------------------------------------------------------
 *
 * main --
 *
 *	Prompts the user for information needed to create a new
 *      account.  Sticks all the info into a buffer and mails it
 *      to the person who will create the account.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Sends mail.
 *
 *----------------------------------------------------------------------
 */
void
main()
{
    static char login_name[BUFFER_SIZE];
    static char full_name[BUFFER_SIZE];
    static char group[BUFFER_SIZE];
    static char home_phone[BUFFER_SIZE];
    static char office[BUFFER_SIZE];
    static char office_phone[BUFFER_SIZE];
    static char project[BUFFER_SIZE];
    static char encrypted_passwd[BUFFER_SIZE];
    static char machine[BUFFER_SIZE];
    const char *shell;
    char *p;
    int y;
    char buffer[0x1000];
    struct group *grp;
    struct passwd *pwd;

    for (;;) {
	printf("Please enter the following information:\n");
	for (;;) {
	    getString(":",  "Login name  ", login_name);
	    if ((pwd = getpwnam(login_name)) != NULL) {
		char *p = pwd->pw_gecos;

		while (*p && *p != ',') {
		    ++p;
		}
		*p = '\0';
		printf("Sorry, `%s' is already in use: %s\n",
		    login_name, pwd->pw_gecos);
		continue;
	    }
	    break;
	}
	getString(":",  "Full name   ", full_name);
	for (;;) {
	    getString(":",  "Group       ", group);
	    if (isdigit(*group)) {
		grp = getgrgid(atoi(group));
	    } else {
		grp = getgrnam(group);
	    }
	    if (grp == NULL) {
		printf("%s is not a valid group\n", group);
		printf("Please try again\n");
		continue;
	    }
	    break;
	}
	getString(":,", "Office      ", office);
	getString(":,", "Office phone", office_phone);
	getString(":,", "Home phone  ", home_phone);
	shell = getShell();
	getPasswd(encrypted_passwd);
	getString("",   "Project     ", project);
	getString("",   "Machine to forward mail to", machine);
	printf("\n\n\n");
	printf("Login name:   %s\n", login_name);
	printf("Full name:    %s\n", full_name);
	printf("Group:        %s %d\n", grp->gr_name, grp->gr_gid);
	printf("Office:       %s\n", office);
	printf("Office phone: %s\n", office_phone);
	printf("Home phone:   %s\n", home_phone);
	printf("Shell:        %s\n", shell);
	printf("Project:      %s\n", project);
	printf("Mail forwarded to: %s\n", machine);
	printf("\n");
	if (yes("Is this correct?")) {
	    break;
	}
    }
    sprintf(buffer,
	"%s\n%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n",
        "Request for New Account",
        "-----------------------",
	"Login name:   ", login_name,
	"password:     "******"Full name:    ", full_name,
	"Group:        ", grp->gr_name,
	"Office:       ", office,
	"Office phone: ", office_phone,
	"Home phone:   ", home_phone,
	"Shell:        ", shell,
	"Project:      ", project,
	"Mail forwarded to: ", machine);
    printf("Sending mail to %s ...", MAIL_WHO);
    mail(MAIL_WHO, buffer);
    printf("\nThank you.  The account will be ready in a few days.\n");
    exit(0);
}