diff --git a/include/xmlTodftfeParser.h b/include/xmlTodftfeParser.h index 078c79e4f..c7367fdd5 100644 --- a/include/xmlTodftfeParser.h +++ b/include/xmlTodftfeParser.h @@ -62,6 +62,9 @@ namespace dftfe std::vector mesh; std::vector>> projectors; + std::vector>> + PSwfc; + std::vector> d_ij; std::ofstream loc_pot; diff --git a/pseudoConverters/upfToxml.cc b/pseudoConverters/upfToxml.cc index c138aae1d..f25b8b62c 100644 --- a/pseudoConverters/upfToxml.cc +++ b/pseudoConverters/upfToxml.cc @@ -298,11 +298,11 @@ namespace dftfe // std::cerr << " upf_mesh_size = " << upf_mesh_size << std::endl; // number of wavefunctions - int upf_nwf; + int upf_nwfc; buf = get_attr(tag, "number_of_wfc"); is.clear(); is.str(buf); - is >> upf_nwf; + is >> upf_nwfc; // std::cerr << " upf_nwf = " << upf_nwf << std::endl; // number of projectors @@ -311,9 +311,12 @@ namespace dftfe is.clear(); is.str(buf); is >> upf_nproj; + + + // std::cerr << " upf_nproj = " << upf_nproj << std::endl; - std::vector upf_l(upf_nwf); + //std::vector upf_l(upf_nwfc); // read mesh find_start_element("PP_MESH", upfFile); @@ -428,6 +431,62 @@ namespace dftfe find_end_element("PP_NONLOCAL", upfFile); + + + find_start_element("PP_PSWFC", upfFile); + std::vector> upf_pswfcdata; + upf_pswfcdata.resize(upf_nwfc); + std::vector upf_wfc_l(upf_nwfc); + std::vector upf_wfc_orbital(upf_nwfc); + int upf_lwfcmax=0; + for (int j = 0; j < upf_nwfc; j++) + { + int index, angular_momentum; + std::string orbital; + os.str(""); + os << j + 1; + std::string element_name = "PP_CHI." + os.str(); + tag = find_start_element(element_name, upfFile); + // std::cerr << tag << std::endl; + + buf = get_attr(tag, "index"); + is.clear(); + is.str(buf); + is >> index; + // std::cerr << " index = " << index << std::endl; + + buf = get_attr(tag, "l"); + is.clear(); + is.str(buf); + is >> angular_momentum; + // std::cerr << " angular_momentum = " << angular_momentum << + // std::endl; + buf = get_attr(tag, "label"); + is.clear(); + is.str(buf); + is >> orbital; + upf_lwfcmax = std::max(upf_lwfcmax,angular_momentum); + upf_wfc_l[index - 1] = angular_momentum; + upf_wfc_orbital[index - 1] = orbital; + upf_pswfcdata[j].resize(upf_mesh_size); + for (int i = 0; i < upf_mesh_size; i++) + upfFile >> upf_pswfcdata[j][i]; + + find_end_element(element_name, upfFile); + } + + // compute number of projectors for each l + // nproj_l[l] is the number of projectors having angular momentum l + std::vector npswfc_l(upf_lwfcmax + 1); + for (int l = 0; l <= upf_lwfcmax; l++) + { + npswfc_l[l] = 0; + for (int ip = 0; ip < upf_nwfc; ip++) + if (upf_wfc_l[ip] == l) + npswfc_l[l]++; + } + find_end_element("PP_PSWFC", upfFile); + // NLCC std::vector upf_nlcc; if (upf_nlcc_flag == "T") @@ -584,6 +643,26 @@ namespace dftfe } } + // PSWFC + for(int iwave = 0; iwave < upf_nwfc; iwave++) + { + xmlFile << "" << std::endl; + int count2 = 0; + for (int j = 0; j < nplin; j++) + { + count2 += 1; + xmlFile << std::setprecision(14) << upf_pswfcdata[iwave][j] + << " "; + if (count2 % 4 == 0) + xmlFile << std::endl; + } + xmlFile << "" << std::endl; + } + + + + // d_ij if (pseudo_type == "NC") { diff --git a/utils/xmlTodftfeParser.cc b/utils/xmlTodftfeParser.cc index 6076d3651..b551eb71f 100644 --- a/utils/xmlTodftfeParser.cc +++ b/utils/xmlTodftfeParser.cc @@ -253,6 +253,63 @@ namespace dftfe projectors.push_back(projector_temp); } + else if (xmlStrcmp(cur_node->name, + (const xmlChar *)"PSwfc") == 0) + { + std::tuple> + PSwfc_temp; + xmlAttr *attribute = cur_node->properties; + int counter = 0; + + while (attribute != nullptr) + { + xmlChar *value = + xmlNodeListGetString(doc, + attribute->children, + 1); + std::string value_str( + reinterpret_cast(value)); + + if (counter == 0) + std::get<0>(PSwfc_temp) = stoi(value_str); + else if (counter == 1) + std::get<1>(PSwfc_temp) = value_str;//stoi(value_str); + + attribute = attribute->next; + counter++; + } + + std::string PSwfc_content( + reinterpret_cast( + xmlNodeGetContent(cur_node))); + + std::string::size_type n = 0; + while ((n = PSwfc_content.find(" ", n)) != + std::string::npos) + { + PSwfc_content.replace(n, 3, ","); + n++; + } + + n = PSwfc_content.find("\n,", 0); + if (n != std::string::npos) + PSwfc_content.replace(n, 2, ""); + + n = 0; + while ((n = PSwfc_content.find("\n", n)) != + std::string::npos) + { + PSwfc_content.replace(n, 1, ""); + n++; + } + + std::istringstream ss(PSwfc_content); + std::string token; + while (std::getline(ss, token, ',')) + std::get<2>(PSwfc_temp).push_back(token); + + PSwfc.push_back(PSwfc_temp); + } else if (xmlStrcmp(cur_node->name, (const xmlChar *)"d_ij") == 0) { @@ -363,6 +420,8 @@ namespace dftfe std::ofstream l3; l3.open(baseOutputPath + "/" + "proj_l3.dat"); + + std::ofstream denom; denom.open(baseOutputPath + "/" + "denom.dat"); @@ -377,7 +436,7 @@ namespace dftfe l0.precision(14); l1.precision(14); l2.precision(14); - l3.precision(14); + l3.precision(14); denom.precision(14); pseudo.precision(14); @@ -388,6 +447,10 @@ namespace dftfe std::vector> l2_vec; std::vector> l3_vec; + // Set up vectors for the wfc values; + + + double r0 = 0.000000000000; double r1 = 0.000000000000; double r2 = 0.000000000000; @@ -411,6 +474,8 @@ namespace dftfe l3_vec.push_back(std::get<2>(i)); } + + // Output mesh_spacing int jl = 0; int jd = 0; @@ -536,6 +601,14 @@ namespace dftfe std::string file2 = "proj_l2.dat"; std::string file3 = "proj_l3.dat"; + j0 = 0; + j1 = 0; + j2 = 0; + j3 = 0; + + + + // Populate the PseudoAtomData file int lead_no = 0; int l0_count = 0; @@ -673,6 +746,22 @@ namespace dftfe denom << std::endl; } + for(auto i:PSwfc) + { + std::ofstream wfc; + std::string orbital = std::get<1>(i); + wfc.open(baseOutputPath+"/"+orbital+".dat"); + pseudo <(i)) + { + wfc << std::fixed << std::setprecision(14) + << mesh[k] /* rp*/ << " " << j << std::endl; + k++; + } + } + // Clear the vectors mult.resize(0); denom_vec.resize(0); @@ -685,6 +774,7 @@ namespace dftfe l1.close(); l2.close(); l3.close(); + denom.close(); pseudo.close(); ad_file.close(); @@ -696,6 +786,7 @@ namespace dftfe coreDensity.clear(); mesh.clear(); projectors.clear(); + PSwfc.clear(); d_ij.clear(); return false;