Changeset 961b75
- Timestamp:
- Apr 21, 2008, 2:19:24 PM (17 years ago)
- Children:
- b74e5e
- Parents:
- e00f47
- git-author:
- Frederik Heber <heber@…> (04/18/08 15:15:13)
- git-committer:
- Frederik Heber <heber@…> (04/21/08 14:19:24)
- Location:
- pcp/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pcp/src/init.c
re00f47 r961b75 1299 1299 * \param type Type of the Parameter to be read 1300 1300 * \param value address of the value to be read (must have been allocated) 1301 * \param repetition determines, if the keyword appears multiply in the config file, which repetition shall be parsed, i.e. 1 if not multiply 1301 1302 * \param critical necessity of this keyword being specified (optional, critical) 1302 1303 * \return 1 - found, 0 - not found 1303 1304 * \sa ReadMainParameterFile Calling routine 1304 1305 */ 1305 int ParseForParameter(int verbose, FILE *file, const char *const name, int sequential, int const xth, int const yth, enum value_type type, void *value, enum necessity critical) {1306 int ParseForParameter(int verbose, FILE *file, const char *const name, int sequential, int const xth, int const yth, enum value_type type, void *value, int repetition, enum necessity critical) { 1306 1307 int i,j; // loop variables 1307 1308 int me, length, maxlength = -1; 1308 1309 long file_position = ftell(file); // mark current position 1309 char *dummy1, *dummy, *free_dummy; // pointers in the line that is read in per step 1310 char *dummy2, *dummy1, *dummy, *free_dummy; // pointers in the line that is read in per step 1311 1312 if (repetition == 0) 1313 Error(SomeError, "ParseForParameter(): argument repetition must not be 0!"); 1314 1315 // allocated memory and rank in multi-process word 1310 1316 dummy1 = free_dummy = (char *) Malloc(256 * sizeof(char),"ParseForParameter: MemAlloc for dummy1 failed"); 1311 1317 MPI_Comm_rank(MPI_COMM_WORLD, &me); 1312 1318 1313 1319 //fprintf(stderr,"(%i) Parsing for %s\n",me,name); 1314 1315 1320 int line = 0; // marks line where parameter was found 1316 1321 int found = (type >= grid) ? 0 : (-yth + 1); // marks if yth parameter name was found 1317 while((found != 1)) {1322 while((found != repetition)) { 1318 1323 dummy1 = dummy = free_dummy; 1319 1324 do { … … 1348 1353 if (name != NULL) { 1349 1354 dummy = strchr(dummy1,'\t'); // set dummy on first tab or space which ever nearer 1350 if (dummy == NULL) {1351 dummy = strchr(dummy1, ' '); // if not found seek for space1352 while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' '))) // skip some more tabs and spaces if necessary1353 dummy ++;1355 dummy2 = strchr(dummy1, ' '); // if not found seek for space 1356 if ((dummy != NULL) || (dummy2 != NULL)) { 1357 if ((dummy == NULL) || ((dummy2 != NULL) && (dummy2 < dummy))) 1358 dummy = dummy2; 1354 1359 } 1355 1360 if (dummy == NULL) { … … 1359 1364 //Error(FileOpenParams, NULL); 1360 1365 } else { 1361 //fprintf(stderr,"(%i) found tab at % i\n",me,(char *)dummy-(char *)dummy1);1366 //fprintf(stderr,"(%i) found tab at %li\n",me,(long)((char *)dummy-(char *)dummy1)); 1362 1367 } 1363 1368 } else dummy = dummy1; 1364 1369 // ... and check if it is the keyword! 1365 if ((name == NULL) || ((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0) )) {1370 if ((name == NULL) || ((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0) && (dummy-dummy1 == strlen(name)))) { 1366 1371 found++; // found the parameter! 1367 1372 //fprintf(stderr,"(%i) found %s at line %i\n",me, name, line); 1368 1373 1369 if (found == 1) {1374 if (found == repetition) { 1370 1375 for (i=0;i<xth;i++) { // i = rows 1371 1376 if (type >= grid) { … … 1413 1418 // otherwise we must skip all interjacent tabs and spaces and find next value 1414 1419 dummy1 = dummy; 1415 dummy = strchr(dummy1, '\t'); // seek for tab or space 1416 if (dummy == NULL) { 1417 dummy = strchr(dummy1, ' '); // if not found seek for space 1418 while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' '))) // skip some more tabs and spaces if necessary 1419 dummy++; 1420 dummy = strchr(dummy1, '\t'); // seek for tab or space (space if appears sooner) 1421 dummy2 = strchr(dummy1, ' '); 1422 //fprintf(stderr,"dummy (%p) is %c\t dummy2 (%p) is %c\n", dummy, (dummy == NULL ? '-' : *dummy), dummy2, (dummy2 == NULL ? '-' : *dummy2)); 1423 if ((dummy != NULL) || (dummy2 != NULL)) { 1424 if ((dummy == NULL) || ((dummy2 != NULL) && (dummy2 < dummy))) 1425 dummy = dummy2; 1426 //while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' '))) // skip some more tabs and spaces if necessary 1427 // dummy++; 1420 1428 } 1421 1429 /* while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' '))) // skip some more tabs and spaces if necessary 1422 1430 dummy++;*/ 1423 if (dummy == NULL) { // if still zero returned ... 1431 //fprintf(stderr,"dummy is %c\n", *dummy); 1432 dummy2 = strchr(dummy1, '#'); 1433 if ((dummy == NULL) || ((dummy2 != NULL) && (dummy1 >= dummy2))) { // if still zero returned or in comment area ... 1424 1434 dummy = strchr(dummy1, '\n'); // ... at line end then 1425 if ((j < yth-1) && (type < 4)) { // check if xth value or not yet 1426 if (verbose) fprintf(stderr,"(%i)Error: EoL at %i and still missing %i value(s) for parameter %s\n", me, line, yth-j, name); 1427 Free(free_dummy, "ParseForParameter: free_dummy"); 1428 return 0; 1435 if ((i < xth-1) && (type < 4)) { // check if xth value or not yet 1436 if (critical) { 1437 if (verbose) fprintf(stderr,"(%i)Error: EoL or comment at %i and still missing %i value(s) for parameter %s\n", me, line, yth-j, name); 1438 Free(free_dummy, "ParseForParameter: free_dummy"); 1439 Error(InitReading, name); 1440 } else { 1441 //if (!sequential) 1442 fseek(file, file_position, SEEK_SET); // rewind to start position 1443 Free(free_dummy, "ParseForParameter: free_dummy"); 1444 return 0; 1445 } 1429 1446 //Error(FileOpenParams, NULL); 1430 1447 } … … 1482 1499 } 1483 1500 if ((type >= row_int) && (verbose)) fprintf(stderr,"\n"); 1501 if (!sequential) fseek(file, file_position, SEEK_SET); // rewind to start position 1484 1502 Free(free_dummy, "ParseForParameter: free_dummy"); 1485 if (!sequential) fseek(file, file_position, SEEK_SET); // rewind to start position1486 1503 //fprintf(stderr, "(%i) End of Parsing\n\n",me); 1487 1504 … … 1503 1520 FILE *file; 1504 1521 int i, di, me; 1505 double BField[NDIM_NDIM];1522 //double BField[NDIM]; 1506 1523 1507 1524 MPI_Comm_rank(MPI_COMM_WORLD, &me); … … 1516 1533 1517 1534 P->Files.filename = MallocString(MAXDUMMYSTRING,"ReadParameters: filename"); 1518 ParseForParameter(P->Call.out[ReadOut],file, "mainname", 0, 1, 1, string_type, P->Files.filename, critical);1535 ParseForParameter(P->Call.out[ReadOut],file, "mainname", 0, 1, 1, string_type, P->Files.filename, 1, critical); 1519 1536 //debug(P,"mainname"); 1520 1537 CreateMainname(P, filename); 1521 1538 P->Files.default_path = MallocString(MAXDUMMYSTRING,"ReadParameters: default_path"); 1522 ParseForParameter(P->Call.out[ReadOut],file, "defaultpath", 0, 1, 1, string_type, P->Files.default_path, critical);1539 ParseForParameter(P->Call.out[ReadOut],file, "defaultpath", 0, 1, 1, string_type, P->Files.default_path, 1, critical); 1523 1540 P->Files.pseudopot_path = MallocString(MAXDUMMYSTRING,"ReadParameters: pseudopot_path"); 1524 ParseForParameter(P->Call.out[ReadOut],file, "pseudopotpath", 0, 1, 1, string_type, P->Files.pseudopot_path, critical);1525 ParseForParameter(P->Call.out[ReadOut],file,"ProcPEGamma", 0, 1, 1, int_type, &(P->Par.proc[PEGamma]), critical);1526 ParseForParameter(P->Call.out[ReadOut],file,"ProcPEPsi", 0, 1, 1, int_type, &(P->Par.proc[PEPsi]), critical);1541 ParseForParameter(P->Call.out[ReadOut],file, "pseudopotpath", 0, 1, 1, string_type, P->Files.pseudopot_path, 1, critical); 1542 ParseForParameter(P->Call.out[ReadOut],file,"ProcPEGamma", 0, 1, 1, int_type, &(P->Par.proc[PEGamma]), 1, critical); 1543 ParseForParameter(P->Call.out[ReadOut],file,"ProcPEPsi", 0, 1, 1, int_type, &(P->Par.proc[PEPsi]), 1, critical); 1527 1544 if (P->Call.proc[PEPsi]) { /* Kommandozeilenoption */ 1528 1545 P->Par.proc[PEPsi] = P->Call.proc[PEPsi]; … … 1532 1549 Run 1533 1550 */ 1534 if (!ParseForParameter(P->Call.out[ReadOut],file,"Seed", 0, 1, 1, int_type, &(R->Seed), optional))1551 if (!ParseForParameter(P->Call.out[ReadOut],file,"Seed", 0, 1, 1, int_type, &(R->Seed), 1, optional)) 1535 1552 R->Seed = 1; 1536 if (!ParseForParameter(P->Call.out[ReadOut],file,"WaveNr", 0, 1, 1, int_type, &(R->WaveNr), optional))1553 if (!ParseForParameter(P->Call.out[ReadOut],file,"WaveNr", 0, 1, 1, int_type, &(R->WaveNr), 1, optional)) 1537 1554 R->WaveNr = 0; 1538 if (!ParseForParameter(P->Call.out[ReadOut],file,"Lambda", 0, 1, 1, double_type, &R->Lambda, optional))1555 if (!ParseForParameter(P->Call.out[ReadOut],file,"Lambda", 0, 1, 1, double_type, &R->Lambda, 1, optional)) 1539 1556 R->Lambda = 1.; 1540 1557 1541 if(!ParseForParameter(P->Call.out[ReadOut],file,"DoOutOrbitals", 0, 1, 1, int_type, &F->DoOutOrbitals, optional)) {1558 if(!ParseForParameter(P->Call.out[ReadOut],file,"DoOutOrbitals", 0, 1, 1, int_type, &F->DoOutOrbitals, 1, optional)) { 1542 1559 F->DoOutOrbitals = 0; 1543 1560 } else { … … 1545 1562 if (F->DoOutOrbitals > 1) F->DoOutOrbitals = 1; 1546 1563 } 1547 ParseForParameter(P->Call.out[ReadOut],file,"DoOutVis", 0, 1, 1, int_type, &F->DoOutVis, critical);1564 ParseForParameter(P->Call.out[ReadOut],file,"DoOutVis", 0, 1, 1, int_type, &F->DoOutVis, 1, critical); 1548 1565 if (F->DoOutVis < 0) F->DoOutVis = 0; 1549 if (F->DoOutVis > 1) F->DoOutVis = 1;1550 if (!ParseForParameter(P->Call.out[ReadOut],file,"VectorPlane", 0, 1, 1, int_type, &R->VectorPlane, optional))1566 if (F->DoOutVis > 2) F->DoOutVis = 1; 1567 if (!ParseForParameter(P->Call.out[ReadOut],file,"VectorPlane", 0, 1, 1, int_type, &R->VectorPlane, 1, optional)) 1551 1568 R->VectorPlane = -1; 1552 1569 if (R->VectorPlane < -1 || R->VectorPlane > 2) { … … 1554 1571 R->VectorPlane = -1; 1555 1572 } 1556 if (!ParseForParameter(P->Call.out[ReadOut],file,"VectorCut", 0, 1, 1, double_type, &R->VectorCut, optional))1573 if (!ParseForParameter(P->Call.out[ReadOut],file,"VectorCut", 0, 1, 1, double_type, &R->VectorCut, 1, optional)) 1557 1574 R->VectorCut = 0.; 1558 ParseForParameter(P->Call.out[ReadOut],file,"DoOutMes", 0, 1, 1, int_type, &F->DoOutMes, critical);1575 ParseForParameter(P->Call.out[ReadOut],file,"DoOutMes", 0, 1, 1, int_type, &F->DoOutMes, 1, critical); 1559 1576 if (F->DoOutMes < 0) F->DoOutMes = 0; 1560 1577 if (F->DoOutMes > 1) F->DoOutMes = 1; 1561 if (!ParseForParameter(P->Call.out[ReadOut],file,"DoOutCurr", 0, 1, 1, int_type, &F->DoOutCurr, optional))1578 if (!ParseForParameter(P->Call.out[ReadOut],file,"DoOutCurr", 0, 1, 1, int_type, &F->DoOutCurr, 1, optional)) 1562 1579 F->DoOutCurr = 0; 1580 if (!ParseForParameter(P->Call.out[ReadOut],file,"DoOutNICS", 0, 1, 1, int_type, &F->DoOutNICS, 1, optional)) 1581 F->DoOutNICS = 0; 1563 1582 if (F->DoOutCurr < 0) F->DoOutCurr = 0; 1564 1583 if (F->DoOutCurr > 1) F->DoOutCurr = 1; 1565 ParseForParameter(P->Call.out[ReadOut],file,"AddGramSch", 0, 1, 1, int_type, &R->UseAddGramSch, critical);1584 ParseForParameter(P->Call.out[ReadOut],file,"AddGramSch", 0, 1, 1, int_type, &R->UseAddGramSch, 1, critical); 1566 1585 if (R->UseAddGramSch < 0) R->UseAddGramSch = 0; 1567 1586 if (R->UseAddGramSch > 2) R->UseAddGramSch = 2; 1568 1587 if(P->Call.out[ReadOut]) fprintf(stderr,"(%i)UseAddGramSch = %i\n",me,R->UseAddGramSch); 1569 if(!ParseForParameter(P->Call.out[ReadOut],file,"CommonWannier", 0, 1, 1, int_type, &R->CommonWannier, optional)) {1588 if(!ParseForParameter(P->Call.out[ReadOut],file,"CommonWannier", 0, 1, 1, int_type, &R->CommonWannier, 1, optional)) { 1570 1589 R->CommonWannier = 0; 1571 1590 } else { … … 1573 1592 if (R->CommonWannier > 4) R->CommonWannier = 4; 1574 1593 } 1575 if(!ParseForParameter(P->Call.out[ReadOut],file,"SawtoothStart", 0, 1, 1, double_type, &P->Lat.SawtoothStart, optional)) {1594 if(!ParseForParameter(P->Call.out[ReadOut],file,"SawtoothStart", 0, 1, 1, double_type, &P->Lat.SawtoothStart, 1, optional)) { 1576 1595 P->Lat.SawtoothStart = 0.01; 1577 1596 } else { … … 1579 1598 if (P->Lat.SawtoothStart > 1.) P->Lat.SawtoothStart = 1.; 1580 1599 } 1581 if (!ParseForParameter(P->Call.out[ReadOut],file,"DoBrent", 0, 1, 1, int_type, &R->DoBrent, optional)) {1600 if (!ParseForParameter(P->Call.out[ReadOut],file,"DoBrent", 0, 1, 1, int_type, &R->DoBrent, 1, optional)) { 1582 1601 R->DoBrent = 0; 1583 1602 } else { … … 1587 1606 1588 1607 1589 ParseForParameter(P->Call.out[ReadOut],file,"MaxOuterStep", 0, 1, 1, int_type, &R->MaxOuterStep, critical); 1608 if (!ParseForParameter(P->Call.out[ReadOut],file,"MaxOuterStep", 0, 1, 1, int_type, &R->MaxOuterStep, 1, optional)) 1609 R->MaxOuterStep = 0; 1610 if (!ParseForParameter(P->Call.out[ReadOut],file,"MaxStructOptStep", 0, 1, 1, int_type, &R->MaxStructOptStep, 1, optional)) { 1611 if (R->MaxOuterStep != 0) { // if StructOptStep not explicitely specified, then use OuterStep 1612 R->MaxStructOptStep = R->MaxOuterStep; 1613 } else { 1614 R->MaxStructOptStep = 100; 1615 } 1616 } 1590 1617 // the following values are MD specific and should be dropped in further revisions 1591 if (!ParseForParameter(P->Call.out[ReadOut],file,"Deltat", 0, 1, 1, double_type, &R->delta_t, optional))1592 R->delta_t = 0;1593 if (!ParseForParameter(P->Call.out[ReadOut],file,"OutVisStep", 0, 1, 1, int_type, &R->OutVisStep, optional))1618 if (!ParseForParameter(P->Call.out[ReadOut],file,"Deltat", 0, 1, 1, double_type, &R->delta_t, 1, optional)) 1619 R->delta_t = 1.; 1620 if (!ParseForParameter(P->Call.out[ReadOut],file,"OutVisStep", 0, 1, 1, int_type, &R->OutVisStep, 1, optional)) 1594 1621 R->OutVisStep = 10; 1595 if (!ParseForParameter(P->Call.out[ReadOut],file,"OutSrcStep", 0, 1, 1, int_type, &R->OutSrcStep, optional))1622 if (!ParseForParameter(P->Call.out[ReadOut],file,"OutSrcStep", 0, 1, 1, int_type, &R->OutSrcStep, 1, optional)) 1596 1623 R->OutSrcStep = 5; 1597 if (!ParseForParameter(P->Call.out[ReadOut],file,"TargetTemp", 0, 1, 1, double_type, &R->TargetTemp, optional))1624 if (!ParseForParameter(P->Call.out[ReadOut],file,"TargetTemp", 0, 1, 1, double_type, &R->TargetTemp, 1, optional)) 1598 1625 R->TargetTemp = 0; 1599 if (!ParseForParameter(P->Call.out[ReadOut],file,"ScaleTempStep", 0, 1, 1, int_type, &R->ScaleTempStep, optional))1600 R->ScaleTempStep = 25;1601 1626 1602 if (!ParseForParameter(P->Call.out[ReadOut],file,"EpsWannier", 0, 1, 1, double_type, &R->EpsWannier, optional))1627 if (!ParseForParameter(P->Call.out[ReadOut],file,"EpsWannier", 0, 1, 1, double_type, &R->EpsWannier, 1, optional)) 1603 1628 R->EpsWannier = 1e-8; 1604 1629 … … 1607 1632 //if (R->MaxOuterStep <= 0) R->MaxOuterStep = 1; 1608 1633 if(P->Call.out[NormalOut]) fprintf(stderr,"(%i)MaxOuterStep = %i\n",me,R->MaxOuterStep); 1609 if(P->Call.out[NormalOut]) fprintf(stderr,"(%i) t = %g\n",me,R->t);1610 ParseForParameter(P->Call.out[ReadOut],file,"MaxPsiStep", 0, 1, 1, int_type, &R->MaxPsiStep, critical);1634 if(P->Call.out[NormalOut]) fprintf(stderr,"(%i)Deltat = %g\n",me,R->delta_t); 1635 ParseForParameter(P->Call.out[ReadOut],file,"MaxPsiStep", 0, 1, 1, int_type, &R->MaxPsiStep, 1, critical); 1611 1636 if (R->MaxPsiStep <= 0) R->MaxPsiStep = 3; 1612 1637 if(P->Call.out[NormalOut]) fprintf(stderr,"(%i)MaxPsiStep = %i\n",me,R->MaxPsiStep); 1613 1638 1614 ParseForParameter(P->Call.out[ReadOut],file,"MaxMinStep", 0, 1, 1, int_type, &R->MaxMinStep, critical);1615 ParseForParameter(P->Call.out[ReadOut],file,"RelEpsTotalE", 0, 1, 1, double_type, &R->RelEpsTotalEnergy, critical);1616 ParseForParameter(P->Call.out[ReadOut],file,"RelEpsKineticE", 0, 1, 1, double_type, &R->RelEpsKineticEnergy, critical);1617 ParseForParameter(P->Call.out[ReadOut],file,"MaxMinStopStep", 0, 1, 1, int_type, &R->MaxMinStopStep, critical);1618 ParseForParameter(P->Call.out[ReadOut],file,"MaxMinGapStopStep", 0, 1, 1, int_type, &R->MaxMinGapStopStep, critical);1639 ParseForParameter(P->Call.out[ReadOut],file,"MaxMinStep", 0, 1, 1, int_type, &R->MaxMinStep, 1, critical); 1640 ParseForParameter(P->Call.out[ReadOut],file,"RelEpsTotalE", 0, 1, 1, double_type, &R->RelEpsTotalEnergy, 1, critical); 1641 ParseForParameter(P->Call.out[ReadOut],file,"RelEpsKineticE", 0, 1, 1, double_type, &R->RelEpsKineticEnergy, 1, critical); 1642 ParseForParameter(P->Call.out[ReadOut],file,"MaxMinStopStep", 0, 1, 1, int_type, &R->MaxMinStopStep, 1, critical); 1643 ParseForParameter(P->Call.out[ReadOut],file,"MaxMinGapStopStep", 0, 1, 1, int_type, &R->MaxMinGapStopStep, 1, critical); 1619 1644 if (R->MaxMinStep <= 0) R->MaxMinStep = R->MaxPsiStep; 1620 1645 if (R->MaxMinStopStep < 1) R->MaxMinStopStep = 1; … … 1622 1647 if(P->Call.out[NormalOut]) fprintf(stderr,"(%i)MaxMinStep = %i\tRelEpsTotalEnergy: %e\tRelEpsKineticEnergy %e\tMaxMinStopStep %i\n",me,R->MaxMinStep,R->RelEpsTotalEnergy,R->RelEpsKineticEnergy,R->MaxMinStopStep); 1623 1648 1624 ParseForParameter(P->Call.out[ReadOut],file,"MaxInitMinStep", 0, 1, 1, int_type, &R->MaxInitMinStep, critical);1625 ParseForParameter(P->Call.out[ReadOut],file,"InitRelEpsTotalE", 0, 1, 1, double_type, &R->InitRelEpsTotalEnergy, critical);1626 ParseForParameter(P->Call.out[ReadOut],file,"InitRelEpsKineticE", 0, 1, 1, double_type, &R->InitRelEpsKineticEnergy, critical);1627 ParseForParameter(P->Call.out[ReadOut],file,"InitMaxMinStopStep", 0, 1, 1, int_type, &R->InitMaxMinStopStep, critical);1628 ParseForParameter(P->Call.out[ReadOut],file,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &R->InitMaxMinGapStopStep, critical);1649 ParseForParameter(P->Call.out[ReadOut],file,"MaxInitMinStep", 0, 1, 1, int_type, &R->MaxInitMinStep, 1, critical); 1650 ParseForParameter(P->Call.out[ReadOut],file,"InitRelEpsTotalE", 0, 1, 1, double_type, &R->InitRelEpsTotalEnergy, 1, critical); 1651 ParseForParameter(P->Call.out[ReadOut],file,"InitRelEpsKineticE", 0, 1, 1, double_type, &R->InitRelEpsKineticEnergy, 1, critical); 1652 ParseForParameter(P->Call.out[ReadOut],file,"InitMaxMinStopStep", 0, 1, 1, int_type, &R->InitMaxMinStopStep, 1, critical); 1653 ParseForParameter(P->Call.out[ReadOut],file,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &R->InitMaxMinGapStopStep, 1, critical); 1629 1654 if (R->MaxInitMinStep <= 0) R->MaxInitMinStep = R->MaxPsiStep; 1630 1655 if (R->InitMaxMinStopStep < 1) R->InitMaxMinStopStep = 1; … … 1633 1658 1634 1659 // Unit cell and magnetic field 1635 ParseForParameter(P->Call.out[ReadOut],file, "BoxLength", 0, 3, 3, lower_trigrid, &P->Lat.RealBasis, critical); /* Lattice->RealBasis */1636 ParseForParameter(P->Call.out[ReadOut],file, "DoPerturbation", 0, 1, 1, int_type, &R->DoPerturbation, optional);1660 ParseForParameter(P->Call.out[ReadOut],file, "BoxLength", 0, 3, 3, lower_trigrid, &P->Lat.RealBasis, 1, critical); /* Lattice->RealBasis */ 1661 ParseForParameter(P->Call.out[ReadOut],file, "DoPerturbation", 0, 1, 1, int_type, &R->DoPerturbation, 1, optional); 1637 1662 if (!R->DoPerturbation) { 1638 if (!ParseForParameter(P->Call.out[ReadOut],file, "BField", 0, 1, 3, grid, & BField, optional)) { // old parameter for perturbation with field direction1663 if (!ParseForParameter(P->Call.out[ReadOut],file, "BField", 0, 1, 3, grid, &R->BField, 1, optional)) { // old parameter for perturbation with field direction 1639 1664 if (P->Call.out[ReadOut]) fprintf(stderr,"(%i) No perturbation specified.\n", P->Par.me); 1640 if (F->DoOutCurr ) {1641 if (P->Call.out[ReadOut]) fprintf(stderr,"(%i) DoOutCurr =1 though no DoPerturbation specified: setting DoOutCurr = 0\n", P->Par.me);1665 if (F->DoOutCurr || F->DoOutNICS) { 1666 if (P->Call.out[ReadOut]) fprintf(stderr,"(%i) DoOutCurr/DoOutNICS = 1 though no DoPerturbation specified: setting DoOutCurr = 0\n", P->Par.me); 1642 1667 F->DoOutCurr = 0; 1668 F->DoOutNICS = 0; 1643 1669 R->DoPerturbation = 0; 1644 1670 } … … 1653 1679 RMatReci3(P->Lat.InvBasis, P->Lat.RealBasis); 1654 1680 1655 if (!ParseForParameter(P->Call.out[ReadOut],file,"DoFullCurrent", 0, 1, 1, int_type, &R->DoFullCurrent, optional))1681 if (!ParseForParameter(P->Call.out[ReadOut],file,"DoFullCurrent", 0, 1, 1, int_type, &R->DoFullCurrent, 1, optional)) 1656 1682 R->DoFullCurrent = 0; 1657 1683 if (R->DoFullCurrent < 0) R->DoFullCurrent = 0; … … 1662 1688 } 1663 1689 1664 ParseForParameter(P->Call.out[ReadOut],file,"ECut", 0, 1, 1, double_type, &P->Lat.ECut, critical);1690 ParseForParameter(P->Call.out[ReadOut],file,"ECut", 0, 1, 1, double_type, &P->Lat.ECut, 1, critical); 1665 1691 if(P->Call.out[NormalOut]) fprintf(stderr,"(%i) ECut = %e -> %e Rydberg\n", me, P->Lat.ECut, 2.*P->Lat.ECut); 1666 ParseForParameter(P->Call.out[ReadOut],file,"MaxLevel", 0, 1, 1, int_type, &P->Lat.MaxLevel, critical);1667 ParseForParameter(P->Call.out[ReadOut],file,"Level0Factor", 0, 1, 1, int_type, &P->Lat.Lev0Factor, critical);1692 ParseForParameter(P->Call.out[ReadOut],file,"MaxLevel", 0, 1, 1, int_type, &P->Lat.MaxLevel, 1, critical); 1693 ParseForParameter(P->Call.out[ReadOut],file,"Level0Factor", 0, 1, 1, int_type, &P->Lat.Lev0Factor, 1, critical); 1668 1694 if (P->Lat.Lev0Factor < 2) { 1669 1695 if(P->Call.out[ReadOut]) fprintf(stderr,"(%i) Set Lev0Factor to 2!\n",me); 1670 1696 P->Lat.Lev0Factor = 2; 1671 1697 } 1672 ParseForParameter(P->Call.out[ReadOut],file,"RiemannTensor", 0, 1, 1, int_type, &di, critical);1698 ParseForParameter(P->Call.out[ReadOut],file,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical); 1673 1699 if (di >= 0 && di < 2) { 1674 1700 P->Lat.RT.Use = (enum UseRiemannTensor)di; … … 1691 1717 P->Lat.MaxLevel = 3; 1692 1718 } 1693 ParseForParameter(P->Call.out[ReadOut],file,"RiemannLevel", 0, 1, 1, int_type, &P->Lat.RT.RiemannLevel, critical);1719 ParseForParameter(P->Call.out[ReadOut],file,"RiemannLevel", 0, 1, 1, int_type, &P->Lat.RT.RiemannLevel, 1, critical); 1694 1720 if(P->Call.out[ReadOut]) fprintf(stderr,"(%i)!RiemannLevel = %i\n",me,P->Lat.RT.RiemannLevel); 1695 1721 if (P->Lat.RT.RiemannLevel < 2) { … … 1701 1727 P->Lat.RT.RiemannLevel = P->Lat.MaxLevel-1; 1702 1728 } 1703 ParseForParameter(P->Call.out[ReadOut],file,"LevRFactor", 0, 1, 1, int_type, &P->Lat.LevRFactor, critical);1729 ParseForParameter(P->Call.out[ReadOut],file,"LevRFactor", 0, 1, 1, int_type, &P->Lat.LevRFactor, 1, critical); 1704 1730 if(P->Call.out[ReadOut]) fprintf(stderr,"(%i)!LevRFactor = %i\n",me,P->Lat.LevRFactor); 1705 1731 if (P->Lat.LevRFactor < 2) { … … 1711 1737 break; 1712 1738 } 1713 ParseForParameter(P->Call.out[ReadOut],file,"PsiType", 0, 1, 1, int_type, &di, critical);1739 ParseForParameter(P->Call.out[ReadOut],file,"PsiType", 0, 1, 1, int_type, &di, 1, critical); 1714 1740 if (di >= 0 && di < 2) { 1715 1741 P->Lat.Psi.Use = (enum UseSpinType)di; … … 1722 1748 switch (P->Lat.Psi.Use) { 1723 1749 case UseSpinDouble: 1724 ParseForParameter(P->Call.out[ReadOut],file,"MaxPsiDouble", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxNoDouble], critical);1725 if (!ParseForParameter(P->Call.out[ReadOut],file,"AddPsis", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxAdd], optional))1750 ParseForParameter(P->Call.out[ReadOut],file,"MaxPsiDouble", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxNoDouble], 1, critical); 1751 if (!ParseForParameter(P->Call.out[ReadOut],file,"AddPsis", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxAdd], 1, optional)) 1726 1752 P->Lat.Psi.GlobalNo[PsiMaxAdd] = 0; 1727 1753 if (P->Lat.Psi.GlobalNo[PsiMaxAdd] != 0) … … 1735 1761 case UseSpinUpDown: 1736 1762 if (P->Par.proc[PEPsi] % 2) Error(SomeError,"UseSpinUpDown & P->Par.proc[PEGamma] % 2"); 1737 ParseForParameter(P->Call.out[ReadOut],file,"PsiMaxNoUp", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxNoUp], critical);1738 ParseForParameter(P->Call.out[ReadOut],file,"PsiMaxNoDown", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxNoDown], critical);1739 if (!ParseForParameter(P->Call.out[ReadOut],file,"AddPsis", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxAdd], optional))1763 ParseForParameter(P->Call.out[ReadOut],file,"PsiMaxNoUp", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxNoUp], 1, critical); 1764 ParseForParameter(P->Call.out[ReadOut],file,"PsiMaxNoDown", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxNoDown], 1, critical); 1765 if (!ParseForParameter(P->Call.out[ReadOut],file,"AddPsis", 0, 1, 1, int_type, &P->Lat.Psi.GlobalNo[PsiMaxAdd], 1, optional)) 1740 1766 P->Lat.Psi.GlobalNo[PsiMaxAdd] = 0; 1741 1767 if (P->Lat.Psi.GlobalNo[PsiMaxAdd] != 0) -
pcp/src/init.h
re00f47 r961b75 29 29 30 30 /* Einlesen der Parameterdatei */ 31 int ParseForParameter(int verbose, FILE *file, const char *const name, int sequential, int const xth, int const yth, enum value_type type, void *value, enum necessity critical);31 int ParseForParameter(int verbose, FILE *file, const char *const name, int sequential, int const xth, int const yth, enum value_type type, void *value, int repetition, enum necessity critical); 32 32 void ReadParameters(struct Problem *const P, const char *const filename); 33 33 -
pcp/src/ions.c
re00f47 r961b75 29 29 #include <string.h> 30 30 #include <unistd.h> 31 #include <gsl/gsl_randist.h> 31 32 #include "mymath.h" 32 33 … … 50 51 #include "init.h" 51 52 53 /** Parses for a given keyword the ion coordinates and velocites. 54 * \param *P Problem at hand, contains pointer to Ion and IonType structure 55 * \param *source 56 * \param *keyword keyword string 57 * \param repetition which repeated version of the keyword shall be read by ReadParameters() 58 * \param relative whether atom coordinates are relative to unit cell size or absolute 59 * \param Bohr conversion factor to atomiclength (e.g. 1.0 if coordinates in bohr radius, 0.529... if given in Angstrom) 60 * \param sigma variance of maxwell-boltzmann distribution 61 * \param *R where to put the read coordinates 62 * \param *U where to put the read velocities 63 * \param *IMT whether its MoveType#FixedIon or not 64 * \return if 1 - success, 0 - failure 65 */ 66 int ParseIonsCoordinatesAndVelocities(struct Problem *P, FILE *source, char *keyword, int repetition, int relative, double sigma, double *R, double *U, int *IMT) 67 { 68 //struct RunStruct *Run = &P->R; 69 struct Ions *I = &P->Ion; 70 struct Lattice *L = &P->Lat; 71 int k; 72 double R_trafo[3]; 73 gsl_rng * r; 74 const gsl_rng_type * T; 75 double Bohr = (I->IsAngstroem) ? ANGSTROEMINBOHRRADIUS : 1.; 76 77 gsl_rng_env_setup(); 78 T = gsl_rng_default; 79 r = gsl_rng_alloc (T); 80 if (ParseForParameter(P->Call.out[ReadOut],source, keyword, 0, 1, 1, double_type, &R_trafo[0], repetition, optional) && 81 ParseForParameter(P->Call.out[ReadOut],source, keyword, 0, 2, 1, double_type, &R_trafo[1], repetition, optional) && 82 ParseForParameter(P->Call.out[ReadOut],source, keyword, 0, 3, 1, double_type, &R_trafo[2], repetition, optional) && 83 ParseForParameter(P->Call.out[ReadOut],source, keyword, 0, 4, 1, int_type, IMT, repetition, optional)) { 84 // if read successful, then try also parsing velocities 85 if ((ParseForParameter(P->Call.out[ReadOut],source, keyword, 0, 5, 1, double_type, &U[0], repetition, optional)) && 86 (ParseForParameter(P->Call.out[ReadOut],source, keyword, 0, 6, 1, double_type, &U[1], repetition, optional)) && 87 (ParseForParameter(P->Call.out[ReadOut],source, keyword, 0, 7, 1, double_type, &U[2], repetition, optional))) { 88 //nothing 89 } else { // if no velocities specified, set to maxwell-boltzmann distributed 90 if ((I->Thermostat != None)) { 91 if (P->Par.me == 0) fprintf(stderr, "(%i) Missing velocities of ion %s: Maxwell-Boltzmann with %lg\n", P->Par.me, keyword, sigma); 92 for (k=0;k<NDIM;k++) 93 U[k] = gsl_ran_gaussian (r, sigma); 94 } else { 95 for (k=0;k<NDIM;k++) 96 U[k] = 0.; 97 } 98 } 99 // change if coordinates were relative 100 if (relative) { 101 //fprintf(stderr,"(%i)Ion coordinates are relative %i ... \n",P->Par.me, relative); 102 RMat33Vec3(R, L->RealBasis, R_trafo); // multiply with real basis 103 } else { 104 for (k=0;k<NDIM;k++) // otherweise just copy to vector 105 R[k] = R_trafo[k]; 106 } 107 // check if given MoveType is valid 108 if (*IMT < 0 || *IMT >= MaxIonMoveType) { 109 fprintf(stderr,"Bad Ion MoveType set to MoveIon for %s\n", keyword); 110 *IMT = 0; 111 } 112 if (!relative) { 113 //fprintf(stderr,"converting with %lg\n", Bohr); 114 SM(R, Bohr, NDIM); // convert angstroem to bohrradius 115 SM(U, Bohr, NDIM); // convert angstroem to bohrradius 116 } 117 // finally periodicly correct coordinates to remain in unit cell 118 RMat33Vec3(R_trafo, L->InvBasis, R); 119 for (k=0; k <NDIM; k++) { // periodic correction until within unit cell 120 while (R_trafo[k] < 0) 121 R_trafo[k] += 1.0; 122 while (R_trafo[k] >= 1.0) 123 R_trafo[k] -= 1.0; 124 } 125 RMat33Vec3(R, L->RealBasis, R_trafo); 126 // print coordinates if desired 127 if ((P->Call.out[ReadOut])) { 128 fprintf(stderr,"(%i) coordinates of Ion %s: (x,y,z) = (",P->Par.me, keyword); 129 for(k=0;k<NDIM;k++) { 130 fprintf(stderr,"%lg ",R[k]); 131 if (k != NDIM-1) fprintf(stderr,", "); 132 else fprintf(stderr,")\n"); 133 } 134 } 135 gsl_rng_free (r); 136 return 1; 137 } else { 138 for (k=0;k<NDIM;k++) { 139 U[k] = R[k] = 0.; 140 } 141 *IMT = 0; 142 gsl_rng_free (r); 143 return 0; 144 } 145 } 146 52 147 /** Readin of the ion section of parameter file. 53 148 * Among others the following paramaters are read from file: … … 60 155 struct Ions *I = &P->Ion; 61 156 //struct RunStruct *Run = &P->R; 62 int i,it,j,IMT,BorAng, d,me, count; 63 struct Lattice *L = &P->Lat; 64 int k; 157 int i,it,j,IMT,d,me, count; 65 158 int relative; // whether read-in coordinate are relative (1) or absolute 66 159 double Bohr = ANGSTROEMINBOHRRADIUS; /* Angstroem */ 67 160 double sigma, R[3], U[3]; 68 161 struct IonConstrained *ptr = NULL; 162 69 163 I->Max_TotalIons = 0; 70 164 I->TotalZval = 0; 71 165 MPI_Comm_rank(MPI_COMM_WORLD, &me); 72 ParseForParameter(P->Call.out[ReadOut],source,"RCut", 0, 1, 1, double_type, &I->R_cut, critical);73 ParseForParameter(P->Call.out[ReadOut],source,"IsAngstroem", 0, 1, 1, int_type, & BorAng, critical);166 ParseForParameter(P->Call.out[ReadOut],source,"RCut", 0, 1, 1, double_type, &I->R_cut, 1, critical); 167 ParseForParameter(P->Call.out[ReadOut],source,"IsAngstroem", 0, 1, 1, int_type, &I->IsAngstroem, 1, critical); 74 168 if (!I->IsAngstroem) { 75 76 169 Bohr = 1.0; 170 } else { // adapt RealBasis (is in Angstroem as well) 77 171 SM(P->Lat.RealBasis, Bohr, NDIM_NDIM); 78 172 RMatReci3(P->Lat.InvBasis, P->Lat.RealBasis); 79 173 } 80 ParseForParameter(P->Call.out[ReadOut],source,"MaxTypes", 0, 1, 1, int_type, &I->Max_Types, critical);174 ParseForParameter(P->Call.out[ReadOut],source,"MaxTypes", 0, 1, 1, int_type, &I->Max_Types, 1, critical); 81 175 I->I = (struct IonType *) Malloc(sizeof(struct IonType)*I->Max_Types, "IonsInitRead: IonType"); 82 if (!ParseForParameter(P->Call.out[ReadOut],source,"RelativeCoord", 0, 1, 1, int_type, &relative, optional))176 if (!ParseForParameter(P->Call.out[ReadOut],source,"RelativeCoord", 0, 1, 1, int_type, &relative, 1, optional)) 83 177 relative = 0; 84 if (!ParseForParameter(P->Call.out[ReadOut],source,"StructOpt", 0, 1, 1, int_type, &I->StructOpt, optional))178 if (!ParseForParameter(P->Call.out[ReadOut],source,"StructOpt", 0, 1, 1, int_type, &I->StructOpt, 1, optional)) 85 179 I->StructOpt = 0; 86 180 181 //InitThermostats(P, source); 182 87 183 /* Ions Data */ 88 184 I->RLatticeVec = NULL; … … 95 191 I->I[i].Name = MallocString(255, "IonsInitRead: Name"); 96 192 I->I[i].Symbol = MallocString(255, "IonsInitRead: Symbol"); 97 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 1, 1, int_type, &I->I[i].Max_IonsOfType, critical);98 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 2, 1, int_type, &I->I[i].Z, critical);99 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 3, 1, double_type, &I->I[i].rgauss, critical);100 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 4, 1, int_type, &I->I[i].l_max, critical);101 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 5, 1, int_type, &I->I[i].l_loc, critical);102 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 6, 1, double_type, &I->I[i].IonMass, critical);103 if(!ParseForParameter(P->Call.out[ReadOut],source, name, 0, 7, 1, string_type, &I->I[i].Name[0], optional))193 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 1, 1, int_type, &I->I[i].Max_IonsOfType, 1, critical); 194 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 2, 1, int_type, &I->I[i].Z, 1, critical); 195 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 3, 1, double_type, &I->I[i].rgauss, 1, critical); 196 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 4, 1, int_type, &I->I[i].l_max, 1, critical); 197 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 5, 1, int_type, &I->I[i].l_loc, 1, critical); 198 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 6, 1, double_type, &I->I[i].IonMass, 1, critical); 199 if(!ParseForParameter(P->Call.out[ReadOut],source, name, 0, 7, 1, string_type, &I->I[i].Name[0], 1, optional)) 104 200 sprintf(&I->I[i].Name[0],"type%i",i); 105 if(!ParseForParameter(P->Call.out[ReadOut],source, name, 0, 8, 1, string_type, &I->I[i].Symbol[0], optional))201 if(!ParseForParameter(P->Call.out[ReadOut],source, name, 0, 8, 1, string_type, &I->I[i].Symbol[0], 1, optional)) 106 202 sprintf(&I->I[i].Symbol[0],"t%i",i); 107 203 if (P->Call.out[ReadOut]) fprintf(stderr,"(%i) Element name: %s, symbol: %s\n",P->Par.me, I->I[i].Name, I->I[i].Symbol); 204 I->I[i].moment = (double **) Malloc(sizeof(double *) * I->I[i].Max_IonsOfType, "IonsInitRead: moment"); 108 205 I->I[i].sigma = (double **) Malloc(sizeof(double *) * I->I[i].Max_IonsOfType, "IonsInitRead: sigma"); 109 206 I->I[i].sigma_rezi = (double **) Malloc(sizeof(double *) * I->I[i].Max_IonsOfType, "IonsInitRead: sigma_rezi"); … … 111 208 I->I[i].sigma_rezi_PAS = (double **) Malloc(sizeof(double *) * I->I[i].Max_IonsOfType, "IonsInitRead: sigma_rezi_PAS"); 112 209 for (it=0;it<I->I[i].Max_IonsOfType;it++) { 210 I->I[i].moment[it] = (double *) Malloc(sizeof(double) * NDIM*NDIM, "IonsInitRead: moment"); 113 211 I->I[i].sigma[it] = (double *) Malloc(sizeof(double) * NDIM*NDIM, "IonsInitRead: sigma"); 114 212 I->I[i].sigma_rezi[it] = (double *) Malloc(sizeof(double) * NDIM*NDIM, "IonsInitRead: sigma_rezi"); … … 117 215 } 118 216 //I->I[i].IonFac = I->I[i].IonMass; 119 I->I[i].IonFac = 1/I->I[i].IonMass; 217 I->I[i].IonMass *= Units2Electronmass; // in config given in amu not in "atomic units" (electron mass, m_e = 1) 218 // proportional factor between electron and proton mass 219 I->I[i].IonFac = Units2Electronmass/I->I[i].IonMass; 120 220 I->TotalMass += I->I[i].Max_IonsOfType*I->I[i].IonMass; 221 sigma = sqrt(P->R.TargetTemp/I->I[i].IonMass); 121 222 I->I[i].ZFactor = -I->I[i].Z*4.*PI; 122 223 I->I[i].alpha = (double *) Malloc(sizeof(double) * I->I[i].Max_IonsOfType, "IonsInitRead: alpha"); … … 124 225 I->I[i].R_old = (double *) Malloc(sizeof(double) *NDIM* I->I[i].Max_IonsOfType, "IonsInitRead: R_old"); 125 226 I->I[i].R_old_old = (double *) Malloc(sizeof(double) *NDIM* I->I[i].Max_IonsOfType, "IonsInitRead: R_old_old"); 227 I->I[i].Constraints = (struct IonConstrained **) Malloc(sizeof(struct IonConstrained *)*I->I[i].Max_IonsOfType, "IonsInitRead: **Constraints"); 228 for (it=0;it<I->I[i].Max_IonsOfType;it++) 229 I->I[i].Constraints[it] = NULL; 126 230 I->I[i].FIon = (double *) Malloc(sizeof(double) * NDIM * I->I[i].Max_IonsOfType, "IonsInitRead: FIon"); 127 231 I->I[i].FIon_old = (double *) Malloc(sizeof(double) * NDIM * I->I[i].Max_IonsOfType, "IonsInitRead: FIon_old"); … … 136 240 I->I[i].FIonL = (double *) Malloc(sizeof(double) * NDIM * I->I[i].Max_IonsOfType, "IonsInitRead: FIonL"); 137 241 I->I[i].FIonNL = (double *) Malloc(sizeof(double) * NDIM * I->I[i].Max_IonsOfType, "IonsInitRead: FIonNL"); 242 I->I[i].FMagnetic = (double *) Malloc(sizeof(double) * NDIM * I->I[i].Max_IonsOfType, "IonsInitRead: FMagnetic"); 243 I->I[i].FConstraint = (double *) Malloc(sizeof(double) * NDIM * I->I[i].Max_IonsOfType, "IonsInitRead: FConstraint"); 138 244 I->I[i].FEwald = (double *) Malloc(sizeof(double) * NDIM * I->I[i].Max_IonsOfType, "IonsInitRead: FEwald"); 139 245 I->I[i].alpha = (double *) Malloc(sizeof(double) * I->I[i].Max_IonsOfType, "IonsInitRead: alpha"); 246 // now parse ion coordination 140 247 for (j=0; j < I->I[i].Max_IonsOfType; j++) { 141 248 I->I[i].alpha[j] = 2.; 142 249 sprintf(name,"Ion_Type%i_%i",i+1,j+1); 143 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 1, 1, double_type, &R[0], critical); 144 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 2, 1, double_type, &R[1], critical); 145 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 3, 1, double_type, &R[2], critical); 146 ParseForParameter(P->Call.out[ReadOut],source, name, 0, 4, 1, int_type, &IMT, critical); 147 // change if coordinates were relative 148 if (relative) { 149 //fprintf(stderr,"(%i)Ion coordinates are relative %i ... \n",P->Par.me, relative); 150 RMat33Vec3(&I->I[i].R[0+NDIM*j], L->RealBasis, R); // multiply with real basis 250 for (d=0; d <NDIM; d++) // transfor to old and old_old coordinates as well 251 I->I[i].FMagnetic[d+j*NDIM] = 0.; 252 // first ones are starting positions 253 if ((count = ParseIonsCoordinatesAndVelocities(P, source, name, 1, relative, sigma, &I->I[i].R[NDIM*j], &I->I[i].U[NDIM*j], &IMT))) { 254 for (d=0; d <NDIM; d++) // transfor to old and old_old coordinates as well 255 I->I[i].R_old_old[d+NDIM*j] = I->I[i].R_old[d+NDIM*j] = I->I[i].R[d+NDIM*j]; 256 I->I[i].IMT[j] = IMT; 257 if (P->Call.out[ReadOut]) fprintf(stderr, "(%i) R[%d,%d] = (%lg, %lg, %lg)\n", P->Par.me, i,j,I->I[i].R[0+NDIM*j],I->I[i].R[1+NDIM*j],I->I[i].R[2+NDIM*j]); 258 if (P->Call.out[ReadOut]) fprintf(stderr, "(%i) U[%d,%d] = (%lg, %lg, %lg)\n", P->Par.me, i,j,I->I[i].U[0+NDIM*j],I->I[i].U[1+NDIM*j],I->I[i].U[2+NDIM*j]); 259 if (P->Call.out[ReadOut]) fprintf(stderr, "(%i) IMT[%d,%d] = %i\n", P->Par.me, i,j,I->I[i].IMT[j]); 151 260 } else { 152 for (k=0;k<NDIM;k++) // and copy to old vector 153 I->I[i].R[k+NDIM*j] = R[k]; 154 } 155 if (IMT < 0 || IMT >= MaxIonMoveType) { 156 fprintf(stderr,"Bad Ion MoveType set to MoveIon for Ion (%i,%i)\n",i,j); 157 IMT = 0; 158 } 159 160 if ((P->Call.out[ReadOut])) { // rotate coordinates 161 fprintf(stderr,"(%i) coordinates of Ion %i: (x,y,z) = (",P->Par.me,j); 162 for(k=0;k<NDIM;k++) { 163 fprintf(stderr,"%lg ",I->I[i].R[k+NDIM*j]); 164 if (k != NDIM-1) fprintf(stderr,", "); 165 else fprintf(stderr,")\n"); 261 Error(SomeError, "Could not find or parse coordinates of an ion"); 262 } 263 // following ones are constrained motions 264 while (ParseIonsCoordinatesAndVelocities(P, source, name, ++count, relative, sigma, R, U, &IMT)) { 265 if (P->Call.out[ReadOut]) fprintf(stderr, "(%i) Constrained read %d ...\n", P->Par.me, count-1); 266 ptr = AddConstraintItem(&I->I[i], j); // allocate memory 267 for (d=0; d< NDIM; d++) { // fill the constraint item 268 ptr->R[d] = R[d]; 269 ptr->U[d] = U[d]; 166 270 } 167 } 168 169 I->I[i].IMT[j] = (enum IonMoveType)IMT; 170 SM(&I->I[i].R[NDIM*j], 1./Bohr, NDIM); 171 RMat33Vec3(R, L->InvBasis, &I->I[i].R[NDIM*j]); 172 for (d=0; d <NDIM; d++) { 173 while (R[d] < 0) 174 R[d] += 1.0; 175 while (R[d] >= 1.0) 176 R[d] -= 1.0; 177 } 178 RMat33Vec3(&I->I[i].R[NDIM*j], L->RealBasis, R); 179 for (d=0; d <NDIM; d++) { 180 I->I[i].R_old_old[d+NDIM*j] = I->I[i].R_old[d+NDIM*j] = I->I[i].R[d+NDIM*j]; 181 } 271 ptr->IMT = IMT; 272 ptr->step = count-1; 273 if (P->Call.out[ReadOut]) fprintf(stderr, "(%i) R[%d,%d] = (%lg, %lg, %lg)\n", P->Par.me, i,j,ptr->R[0],ptr->R[1],ptr->R[2]); 274 if (P->Call.out[ReadOut]) fprintf(stderr, "(%i) U[%d,%d] = (%lg, %lg, %lg)\n", P->Par.me, i,j,ptr->U[0],ptr->U[1],ptr->U[2]); 275 if (P->Call.out[ReadOut]) fprintf(stderr, "(%i) IMT[%d,%d] = %i\n", P->Par.me, i,j,ptr->IMT); 276 } 277 //if (P->Call.out[ReadOut]) 278 fprintf(stderr,"(%i) A total of %d additional constrained moves for ion (%d,%d) was parsed.\n", P->Par.me, count-2, i,j); 279 182 280 I->Max_TotalIons++; 183 281 } -
pcp/src/ions.h
re00f47 r961b75 121 121 /* Functions */ 122 122 void IonsInitRead(struct Problem *P, FILE *source); 123 void InitThermostats(struct Problem *P, FILE *source);124 123 void CalculateEwald(struct Problem *P, int first); 125 124 void RemoveIonsRead(struct Ions *I); … … 138 137 void ResetForces(struct Problem *P); 139 138 void CorrectVelocity(struct Problem *P); 139 struct IonConstrained * AddConstraintItem(struct IonType *I, int ion); 140 int RemoveConstraintItem(struct IonType *I, int ion); 140 141 #endif -
pcp/src/output.c
re00f47 r961b75 606 606 } 607 607 // ... and parse critical ... 608 readnr += ParseForParameter(0,SrcPsiDoc,"Mintype",0,1,1,int_type,(int *)&read_type, test ? optional : critical);609 readnr += ParseForParameter(0,SrcPsiDoc,"LevelNo",0,1,1,int_type,&LevelNo, test ? optional : critical);610 readnr += 3*ParseForParameter(0,SrcPsiDoc,"GridNodes",0,3,1,row_int,&N[0], test ? optional : critical);611 readnr += 2*ParseForParameter(0,SrcPsiDoc,"PsiNo",0,2,1,row_int,&GlobalNo[0], test ? optional : critical);608 readnr += ParseForParameter(0,SrcPsiDoc,"Mintype",0,1,1,int_type,(int *)&read_type, 1, test ? optional : critical); 609 readnr += ParseForParameter(0,SrcPsiDoc,"LevelNo",0,1,1,int_type,&LevelNo,1, test ? optional : critical); 610 readnr += 3*ParseForParameter(0,SrcPsiDoc,"GridNodes",0,3,1,row_int,&N[0], 1, test ? optional : critical); 611 readnr += 2*ParseForParameter(0,SrcPsiDoc,"PsiNo",0,2,1,row_int,&GlobalNo[0], 1, test ? optional : critical); 612 612 // and optional items ... 613 if (ParseForParameter(0,SrcPsiDoc,"Epsilon",0,2,1,row_double,&Eps[0], optional))613 if (ParseForParameter(0,SrcPsiDoc,"Epsilon",0,2,1,row_double,&Eps[0],1,optional)) 614 614 if ((P->Call.ReadSrcFiles == 1) && ((Eps[1] < R->RelEpsKineticEnergy) || (Eps[0] < R->RelEpsTotalEnergy))) { 615 615 //fprintf(stderr,"(%i) Eps %lg %lg\tRelEps %lg %lg\n", P->Par.me, Eps[0], Eps[1], R->RelEpsTotalEnergy, R->RelEpsKineticEnergy); -
pcp/src/perturbed.c
re00f47 r961b75 2314 2314 int wished = -1; 2315 2315 FILE *file = fopen(P->Call.MainParameterFile,"r"); 2316 if (!ParseForParameter(1,file,"Orbital",0,1,1,int_type,&wished, optional)) {2316 if (!ParseForParameter(1,file,"Orbital",0,1,1,int_type,&wished, 1, optional)) { 2317 2317 fprintf(stderr,"Desired Orbital missing!\n"); 2318 2318 wished = -1; -
pcp/src/pseudo.c
re00f47 r961b75 506 506 if (P->Call.out[ReadOut]) fprintf(stderr,"%s was found\n",cpiInputFileName); 507 507 int zeile = 1; 508 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &PP->zval[it], critical);509 ParseForParameter(0,cpiInputFile, NULL, 1, 2, zeile, int_type, &PP->nang[it], critical);508 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &PP->zval[it], 1, critical); 509 ParseForParameter(0,cpiInputFile, NULL, 1, 2, zeile, int_type, &PP->nang[it], 1, critical); 510 510 I->TotalZval += PP->zval[it]*(I->I[it].Max_IonsOfType); 511 511 PP->core[it] = (double *) Malloc(sizeof(double)*2, "InitPseudoRead: "); 512 512 PP->rc[it] = (double *) Malloc(sizeof(double)*2, "InitPseudoRead: "); 513 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &PP->core[it][0], critical);514 ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &PP->rc[it][0], critical);515 ParseForParameter(0,cpiInputFile, NULL, 0, 3, zeile, double_type, &PP->core[it][1], critical);516 ParseForParameter(0,cpiInputFile, NULL, 1, 4, zeile, double_type, &PP->rc[it][1], critical);513 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &PP->core[it][0], 1, critical); 514 ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &PP->rc[it][0], 1, critical); 515 ParseForParameter(0,cpiInputFile, NULL, 0, 3, zeile, double_type, &PP->core[it][1], 1, critical); 516 ParseForParameter(0,cpiInputFile, NULL, 1, 4, zeile, double_type, &PP->rc[it][1], 1, critical); 517 517 PP->rcl[it] = (double **) Malloc(sizeof(double*)*3, "InitPseudoRead: "); 518 518 PP->al[it] = (double **) Malloc(sizeof(double*)*3, "InitPseudoRead: "); … … 526 526 PP->bl[it][il] = (double *) Malloc(sizeof(double)*3, "InitPseudoRead: "); 527 527 for (ib = 0; ib < 3; ib++) { 528 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &PP->rcl[it][il][ib], critical);529 ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &PP->al[it][il][ib], critical);530 ParseForParameter(0,cpiInputFile, NULL, 1, 3, zeile, double_type, &PP->bl[it][il][ib], critical);528 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &PP->rcl[it][il][ib], 1, critical); 529 ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &PP->al[it][il][ib], 1, critical); 530 ParseForParameter(0,cpiInputFile, NULL, 1, 3, zeile, double_type, &PP->bl[it][il][ib], 1, critical); 531 531 if (PP->rcl[it][il][ib] < MYEPSILON) 532 532 PP->rcl[it][il][ib] = 0.0; … … 535 535 } 536 536 } 537 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, int_type, &PP->mmax[it], critical);538 ParseForParameter(0,cpiInputFile, NULL, 1, 2, zeile, double_type, &PP->clog[it], critical);537 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, int_type, &PP->mmax[it], 1, critical); 538 ParseForParameter(0,cpiInputFile, NULL, 1, 2, zeile, double_type, &PP->clog[it], 1, critical); 539 539 if (PP->mmax[it] > PP->Mmax) PP->Mmax = PP->mmax[it]; 540 540 PP->clog[it] = log(PP->clog[it]); … … 547 547 PP->v_loc[it][il] = (double *) Malloc(sizeof(double)*PP->mmax[it], "InitPseudoRead: "); 548 548 for (j=0;j< PP->mmax[it];j++) { 549 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, int_type, &m, critical);550 ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &PP->r[it][j], critical);551 ParseForParameter(0,cpiInputFile, NULL, 0, 3, zeile, double_type, &PP->R[it][il][j], critical);552 ParseForParameter(0,cpiInputFile, NULL, 1, 4, zeile, double_type, &PP->v_loc[it][il][j], critical);549 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, int_type, &m, 1, critical); 550 ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &PP->r[it][j], 1, critical); 551 ParseForParameter(0,cpiInputFile, NULL, 0, 3, zeile, double_type, &PP->R[it][il][j], 1, critical); 552 ParseForParameter(0,cpiInputFile, NULL, 1, 4, zeile, double_type, &PP->v_loc[it][il][j], 1, critical); 553 553 } 554 554 if (il < PP->nang[it]-1) { 555 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, int_type, &PP->mmax[it], critical);556 ParseForParameter(0,cpiInputFile, NULL, 1, 2, zeile, double_type, &PP->clog[it], critical);555 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, int_type, &PP->mmax[it], 1, critical); 556 ParseForParameter(0,cpiInputFile, NULL, 1, 2, zeile, double_type, &PP->clog[it], 1, critical); 557 557 PP->clog[it] = log(PP->clog[it]); 558 558 } … … 560 560 I->I[it].corecorr = NotCoreCorrected; 561 561 count = 0; 562 count += ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &dummyr, optional);563 count += ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &dummycorewave, optional);562 count += ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &dummyr, 1, optional); 563 count += ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &dummycorewave, 1, optional); 564 564 //fprintf(stderr,"(%i) %lg %lg\n",P->Par.me,dummyr,dummycorewave); 565 565 if (count == 2) { … … 570 570 PP->corecorr = CoreCorrected; 571 571 PP->corewave[it][0] = dummycorewave/(4.*PI); 572 ParseForParameter(0,cpiInputFile, NULL, 0, 3, zeile, double_type, &dummyr, critical);573 ParseForParameter(0,cpiInputFile, NULL, 1, 4, zeile, double_type, &dummycorewave, critical);572 ParseForParameter(0,cpiInputFile, NULL, 0, 3, zeile, double_type, &dummyr, 1, critical); 573 ParseForParameter(0,cpiInputFile, NULL, 1, 4, zeile, double_type, &dummycorewave, 1, critical); 574 574 for (j=1;j < PP->mmax[it]; j++) { 575 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &PP->r[it][j], critical);576 ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &PP->corewave[it][j], critical);577 ParseForParameter(0,cpiInputFile, NULL, 0, 3, zeile, double_type, &dummyr, critical);578 ParseForParameter(0,cpiInputFile, NULL, 1, 4, zeile, double_type, &dummycorewave, critical);575 ParseForParameter(0,cpiInputFile, NULL, 0, 1, zeile, double_type, &PP->r[it][j], 1, critical); 576 ParseForParameter(0,cpiInputFile, NULL, 0, 2, zeile, double_type, &PP->corewave[it][j], 1, critical); 577 ParseForParameter(0,cpiInputFile, NULL, 0, 3, zeile, double_type, &dummyr, 1, critical); 578 ParseForParameter(0,cpiInputFile, NULL, 1, 4, zeile, double_type, &dummycorewave, 1, critical); 579 579 PP->corewave[it][j] /= (4.*PI); 580 580 } -
pcp/src/wannier.c
re00f47 r961b75 1319 1319 sprintf(tagname,"Psi%d_Lev%d",i,R->LevSNo); 1320 1320 signal = 0; 1321 if (!ParseForParameter(0,SpreadFile,tagname,0,3,1,row_double,WannierCentre, optional)) {1321 if (!ParseForParameter(0,SpreadFile,tagname,0,3,1,row_double,WannierCentre,1,optional)) { 1322 1322 //Error(SomeError,"ParseWannierFile: Parsing WannierCentre failed"); 1323 1323 if (MPI_Bcast(&signal,1,MPI_INT,0,P->Par.comm_ST) != MPI_SUCCESS) … … 1325 1325 return 0; 1326 1326 } 1327 if (!ParseForParameter(0,SpreadFile,tagname,0,4,1,double_type,&WannierCentre[NDIM], optional)) {1327 if (!ParseForParameter(0,SpreadFile,tagname,0,4,1,double_type,&WannierCentre[NDIM],1,optional)) { 1328 1328 //Error(SomeError,"ParseWannierFile: Parsing WannierSpread failed"); 1329 1329 if (MPI_Bcast(&signal,1,MPI_INT,0,P->Par.comm_ST) != MPI_SUCCESS)
Note:
See TracChangeset
for help on using the changeset viewer.