@@ -453,7 +453,8 @@ void Force_Stress_LCAO::getForceStress(
453453 // caoyu add 2021-06-03
454454 if (GlobalV::deepks_scf)
455455 {
456- this ->print_force (" DeePKS FORCE" , GlobalC::ld.F_delta , 1 , ry);
456+ f_pw.print (" DeePKS FORCE" , GlobalC::ld.F_delta , 1 );
457+ // this->print_force("DeePKS FORCE", GlobalC::ld.F_delta, 1, ry);
457458 }
458459#endif
459460 }
@@ -623,143 +624,6 @@ void Force_Stress_LCAO::getForceStress(
623624 return ;
624625}
625626
626- // print force term for test
627- void Force_Stress_LCAO::print_force (const std::string &name, ModuleBase::matrix& f, const bool screen, bool ry)const
628- {
629- GlobalV::ofs_running << " --------------------------- " << name << " ----------------------------" << std::endl;
630- GlobalV::ofs_running << " " << std::setw (8 ) << " atom" << std::setw (15 ) << " x" << std::setw (15 ) << " y" << std::setw (15 ) << " z" << std::endl;
631-
632- double fac = 1.0 ;
633-
634- if (!ry)
635- {
636- fac = ModuleBase::Ry_to_eV / 0.529177 ;
637- }
638-
639- std::cout << std::setprecision (5 );
640- std::cout << std::setiosflags (ios::showpos);
641-
642- if (screen)
643- {
644- std::cout << " ------------------- " << name << " --------------------" << std::endl;
645- std::cout << " " << std::setw (8 ) << " atom" << std::setw (15 ) << " x" << std::setw (15 ) << " y" << std::setw (15 ) << " z" << std::endl;
646- }
647-
648- int iat = 0 ;
649- for (int it = 0 ;it < GlobalC::ucell.ntype ;it++)
650- {
651- for (int ia = 0 ;ia < GlobalC::ucell.atoms [it].na ;ia++)
652- {
653- std::stringstream ss;
654- ss << GlobalC::ucell.atoms [it].label << ia+1 ;
655-
656- GlobalV::ofs_running << " " << std::setw (8 ) << ss.str ();
657- if ( abs (f (iat,0 )) >output_acc) GlobalV::ofs_running << std::setw (15 ) << f (iat,0 )*fac;
658- else GlobalV::ofs_running << std::setw (15 ) << " 0" ;
659- if ( abs (f (iat,1 )) >output_acc) GlobalV::ofs_running << std::setw (15 ) << f (iat,1 )*fac;
660- else GlobalV::ofs_running << std::setw (15 ) << " 0" ;
661- if ( abs (f (iat,2 )) >output_acc) GlobalV::ofs_running << std::setw (15 ) << f (iat,2 )*fac;
662- else GlobalV::ofs_running << std::setw (15 ) << " 0" ;
663- GlobalV::ofs_running << std::endl;
664-
665- if (screen)
666- {
667- std::cout << " " << std::setw (8 ) << ss.str ();
668- if ( abs (f (iat,0 )) >output_acc) std::cout << std::setw (15 ) << f (iat,0 )*fac;
669- else std::cout << std::setw (15 ) << " 0" ;
670- if ( abs (f (iat,1 )) >output_acc) std::cout << std::setw (15 ) << f (iat,1 )*fac;
671- else std::cout << std::setw (15 ) << " 0" ;
672- if ( abs (f (iat,2 )) >output_acc) std::cout << std::setw (15 ) << f (iat,2 )*fac;
673- else std::cout << std::setw (15 ) << " 0" ;
674- std::cout << std::endl;
675- }
676-
677- iat++;
678- }
679- }
680-
681-
682- std::cout << std::resetiosflags (ios::showpos);
683-
684- return ;
685- }
686-
687-
688- void Force_Stress_LCAO::printforce_total (const bool ry, const bool istestf, ModuleBase::matrix& fcs)
689- {
690- ModuleBase::TITLE (" Force_Stress_LCAO" ," printforce_total" );
691- double unit_transform = 1 ;
692-
693- if (!ry)
694- {
695- unit_transform = ModuleBase::Ry_to_eV / 0.529177 ;
696- }
697- // std::cout.setf(ios::fixed);
698-
699- int iat=0 ;
700-
701- // GlobalV::ofs_running << std::setiosflags(ios::right);
702- GlobalV::ofs_running << std::setprecision (6 ) << std::setiosflags (ios::showpos) << std::setiosflags (ios::fixed) << std::endl;
703- ModuleBase::GlobalFunc::NEW_PART (" TOTAL-FORCE (eV/Angstrom)" );
704-
705- // print out forces
706- if (INPUT.out_force == 1 )
707- {
708- std::ofstream ofs (" FORCE.dat" );
709- if (!ofs)
710- {
711- std::cout << " open FORCE.dat error !" <<std::endl;
712- }
713-
714- for (int iat=0 ; iat<GlobalC::ucell.nat ; iat++)
715- {
716- ofs << " " << fcs (iat,0 )*ModuleBase::Ry_to_eV / 0.529177
717- << " " << fcs (iat,1 )*ModuleBase::Ry_to_eV / 0.529177
718- << " " << fcs (iat,2 )*ModuleBase::Ry_to_eV / 0.529177 << std::endl;
719- }
720- ofs.close ();
721- }
722-
723- if (istestf)
724- {
725- cout << setprecision (6 );
726- // cout << setiosflags(ios::showpos);
727- // cout << setiosflags(ios::fixed) << endl;
728- cout << " ------------------- TOTAL FORCE --------------------" << endl;
729- cout << " " << setw (8 ) << " Atom" << setw (15 ) << " x" << setw (15 ) << " y" << setw (15 ) << " z" << endl;
730- GlobalV::ofs_running << " " << setw (12 ) << " Atom" << setw (15 ) << " x" << setw (15 ) << " y" << setw (15 ) << " z" << endl;
731- }
732-
733- iat=0 ;
734- for (int it=0 ; it<GlobalC::ucell.ntype ; it++)
735- {
736- for (int ia = 0 ; ia < GlobalC::ucell.atoms [it].na ; ia++)
737- {
738- std::stringstream ss;
739- ss << GlobalC::ucell.atoms [it].label << ia+1 ;
740-
741- if (istestf)
742- {
743- std::cout << " " << std::setw (8 ) << ss.str ()
744- << std::setw (15 ) << fcs (iat,0 )*unit_transform
745- << std::setw (15 ) << fcs (iat,1 )*unit_transform
746- << std::setw (15 ) << fcs (iat,2 )*unit_transform << std::endl;
747- }
748-
749- GlobalV::ofs_running << " " << std::setw (12 ) << ss.str ()
750- << std::setw (15 ) << fcs (iat,0 )*unit_transform
751- << std::setw (15 ) << fcs (iat,1 )*unit_transform
752- << std::setw (15 ) << fcs (iat,2 )*unit_transform << std::endl;
753-
754- ++iat;
755- }
756- }
757- GlobalV::ofs_running << std::setiosflags (ios::left);
758- std::cout << std::resetiosflags (ios::showpos);
759-
760- return ;
761- }
762-
763627// local pseudopotential, ewald, core correction, scc terms in force
764628void Force_Stress_LCAO::calForcePwPart (
765629 ModuleBase::matrix &fvl_dvl,
0 commit comments