| 357 | } |
| 358 | |
| 359 | PotcarDataset parse_dataset_block(const std::string& block_text, std::size_t dataset_index) { |
| 360 | const auto lines = split_lines(block_text); |
| 361 | if (lines.empty()) { |
| 362 | throw std::runtime_error("parse_potcar: encountered empty dataset block"); |
| 363 | } |
| 364 | |
| 365 | PotcarDataset dataset; |
| 366 | std::size_t local_part_idx = lines.size(); |
| 367 | std::size_t kinetic_error_idx = lines.size(); |
| 368 | std::size_t paw_radial_sets_idx = lines.size(); |
| 369 | std::size_t augmentation_idx = lines.size(); |
| 370 | std::size_t occupancies_idx = lines.size(); |
| 371 | std::size_t core_charge_partial_idx = lines.size(); |
| 372 | std::size_t core_charge_idx = lines.size(); |
| 373 | std::size_t core_charge_pseudo_idx = lines.size(); |
| 374 | std::size_t atomic_rho_idx = lines.size(); |
| 375 | std::vector<std::size_t> pseudo_wave_idxs; |
| 376 | std::vector<std::size_t> ae_wave_idxs; |
| 377 | std::vector<std::size_t> nonlocal_idxs; |
| 378 | bool has_enmax = false; |
| 379 | bool has_zval = false; |
| 380 | bool has_mass = false; |
| 381 | |
| 382 | std::string first_nonempty_line; |
| 383 | for (std::size_t i = 0; i < lines.size(); ++i) { |
| 384 | const std::string trimmed = trim_copy(lines[i]); |
| 385 | const std::string lower_trimmed = lower_copy(trimmed); |
| 386 | if (first_nonempty_line.empty() && !trimmed.empty()) { |
| 387 | first_nonempty_line = trimmed; |
| 388 | } |
| 389 | |
| 390 | if (starts_with(lower_trimmed, "titel")) { |
| 391 | dataset.titel = extract_title_value(trimmed); |
| 392 | } |
| 393 | if (!has_enmax) { |
| 394 | if (const auto v = extract_value_by_key(lines[i], "ENMAX")) { |
| 395 | dataset.enmax_ev = *v; |
| 396 | has_enmax = true; |
| 397 | } |
| 398 | } |
| 399 | if (!has_zval) { |
| 400 | if (const auto v = extract_value_by_key(lines[i], "ZVAL")) { |
| 401 | dataset.zval = *v; |
| 402 | has_zval = true; |
| 403 | } |
| 404 | } |
| 405 | if (!has_mass) { |
| 406 | if (const auto v = extract_value_by_key(lines[i], "POMASS")) { |
| 407 | dataset.mass_amu = *v; |
| 408 | has_mass = true; |
| 409 | } |
| 410 | } |
| 411 | if (!dataset.has_eatom) { |
| 412 | if (const auto v = extract_value_by_key(lines[i], "EATOM")) { |
| 413 | dataset.eatom_ev = *v; |
| 414 | dataset.has_eatom = true; |
| 415 | } |
| 416 | } |
no test coverage detected