Skip to content

Commit

Permalink
Fix: support negative value in parse_expression (#5826)
Browse files Browse the repository at this point in the history
* Use template to reconstruct parse_expression

* Feature: output R matrix at each MD step

* Modify'matrix_HS' to 'matrix' for R matrix output

* Merge branches 'develop' and 'develop' of https://github.com/1041176461/abacus-develop into develop

* Fix: modify index in parse_expression

* Fix: add regfree for parse_expression

* Doc: update phonopy doc

* Doc: update phonopy doc

* fix tdos plot for nspin=2

* optimize dosplot for nspin=2

* fix legend for dosplot

* Add files via upload

* Update cal_edm_tddft.cpp

* Refactor: modify exx loop for relax/md

* Update result.ref

* Fix wrong parameters in integrate test

* Update result.ref

* Update result.ref

* Update result.ref

* Update result.ref

* Update result.ref

* Update result.ref

* Update result.ref

* Update result.ref

* add exx when istep>0

* Update dos.py

* Update esolver_sdft_pw.cpp

* Update lcao_before_scf.cpp

* Update Exx_LRI_interface.h

* Update Exx_LRI_interface.hpp

* Fix: compile error

* Fix: compile error

* Fix: change HSE relax/md result.ref for new framework

* Fix: compile error

* compatible with exx_iter_finish

* Add files via upload

* Update esolver_ks_lcao_tddft.h

* Update esolver_ks_lcao_tddft.cpp

* Fix: support negative value in parse_expression

* [pre-commit.ci lite] apply automatic fixes

---------

Co-authored-by: jiyuang <[email protected]>
Co-authored-by: Qianrui <[email protected]>
Co-authored-by: HTZhao <[email protected]>
Co-authored-by: maki49 <[email protected]>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
6 people authored Jan 7, 2025
1 parent cdf1c04 commit 39aab7a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/module_io/input_conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <iomanip>
#include <iostream>
#include <regex.h>
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
Expand All @@ -31,7 +31,7 @@ void tmp_convert();
* @brief Pass the data members from the INPUT instance(defined in
* module_io/input.cpp) to GlobalV and GlobalC.
*/
void Convert(void);
void Convert();

/**
* @brief To parse input parameters as expressions into vectors
Expand All @@ -47,7 +47,7 @@ void parse_expression(const std::string& fn, std::vector<T>& vec)
{
ModuleBase::TITLE("Input_Conv", "parse_expression");
int count = 0;
std::string pattern("([0-9]+\\*[0-9.]+|[0-9,.]+)");
std::string pattern("([-+]?[0-9]+\\*[-+]?[0-9.]+|[-+]?[0-9,.]+)");
std::vector<std::string> str;
std::stringstream ss(fn);
std::string section;
Expand Down Expand Up @@ -103,6 +103,7 @@ void parse_expression(const std::string& fn, std::vector<T>& vec)
{
size_t pos = sub_str.find("*");
int num = stoi(sub_str.substr(0, pos));
assert(num>=0);
T occ = stof(sub_str.substr(pos + 1, sub_str.size()));
// std::vector<double> ocp_temp(num, occ);
// const std::vector<double>::iterator dest = vec.begin() + count;
Expand Down

0 comments on commit 39aab7a

Please sign in to comment.