14 string KIRA::Fout(
const ex & expr) {
16 if(is_a<lst>(f)) f = F(f);
17 else if(expr.match(F(
w1,
w2))) f = F(f.op(1));
29 ex KIRA::Fin(
const string & expr) {
45 auto rc = system((
"rm -rf "+job_dir).c_str());
46 if(!
dir_exists(job_dir)) system((
"mkdir -p "+job_dir).c_str());
48 string config_dir = job_dir +
"/config";
49 rc = system((
"rm -rf "+config_dir).c_str());
50 if(!
dir_exists(config_dir)) rc = system((
"mkdir -p "+config_dir).c_str());
55 oss <<
"integralfamilies:" << endl;
56 oss <<
" - name: F" << endl;
57 oss <<
" loop_momenta: [";
58 for(
int i=0; i<
Internal.nops(); i++) {
61 else oss <<
"]" << endl;
64 vector<int> symbolic_ibp;
65 for(
auto kv :
Shift) {
66 if(kv.second.is_zero())
continue;
67 symbolic_ibp.push_back(kv.first);
69 if(symbolic_ibp.size()>0) {
70 oss <<
" symbolic_ibp: [";
71 for(
int i=0; i<symbolic_ibp.size(); i++) {
73 oss << symbolic_ibp[i];
79 oss <<
" propagators:" << endl;
81 oss <<
" - [ \"" <<
Propagator.op(i) <<
"\", 0]" << endl;
84 oss <<
" cut_propagators: [";
85 for(
auto i=0; i<
Cut.nops(); i++) {
87 if(i+1<
Cut.nops()) oss <<
", ";
88 else oss <<
"]" << endl;
91 ofstream if_out(config_dir+
"/integralfamilies.yaml");
92 if_out << oss.str() << endl;
99 oss <<
"kinematics:" << endl;
100 oss <<
" incoming_momenta: [";
101 for(
int i=0; i<
External.nops(); i++) {
103 if(i+1<
External.nops()) oss <<
", ";
104 else oss <<
"]" << endl;
113 repl.append(
w*item.op(0) ==
w*item.op(1));
120 for(
auto vi : vars) vset_all.insert(vi);
122 for(
auto vi :
Internal) vset_mom.insert(vi);
123 for(
auto vi :
External) vset_mom.insert(vi);
125 for(
auto vi : vset_all) {
126 if(vset_mom.find(vi) == vset_mom.end()) vset.insert(vi);
129 oss <<
" kinematic_invariants:" << endl;
130 for(
auto vi : vset) oss <<
" - [ " << vi <<
", 0 ]" << endl;
131 for(
auto i : symbolic_ibp) oss <<
" - [ b" << (i-1) <<
", 0 ]" << endl;
134 oss <<
" scalarproduct_rules:" << endl;
135 for(
int i=0; i<
External.nops(); i++) {
137 for(
int j=i; j<
External.nops(); j++) {
139 oss <<
" - [ [" << pi <<
"," << pj <<
"], ";
146 ofstream km_out(config_dir+
"/kinematics.yaml");
147 km_out << oss.str() << endl;
155 if(_rmax < 0 || _smax < 0) {
161 for(
auto item : integral) {
162 if(item>0) rr +=
ex2int(item);
165 if(rrmax<rr) rrmax = rr;
166 if(ssmax<ss) ssmax = ss;
168 if(rrmax > _rmax) _rmax = rrmax;
169 if(ssmax > _smax) _smax = ssmax;
175 oss <<
"jobs:" << endl;
176 oss <<
" - reduce_sectors:" << endl;
177 oss <<
" reduce: " << endl;
178 oss <<
" - {r: " << _rmax <<
", s: " << _smax <<
"}" << endl;
179 oss <<
" select_integrals: " << endl;
180 oss <<
" select_mandatory_recursively: " << endl;
181 oss <<
" - {r: " << _rmax <<
", s: " << _smax;
184 oss <<
" run_initiate: true" << endl;
185 oss <<
" run_triangular: true" << endl;
186 oss <<
" run_back_substitution: true" << endl;
190 for(
int i=0; i<nn; i++) oss2 << Fout(
PIntegral.op(i)) << endl;
191 ofstream pref_out(job_dir+
"/preferred");
192 pref_out << oss2.str() << endl;
194 oss <<
" preferred_masters: preferred" << endl;
196 oss <<
" - kira2file:" << endl;
197 oss <<
" target:" << endl;
198 oss <<
" - [F,integrals]" << endl;
199 ofstream job_out(job_dir+
"/job.yaml");
200 job_out << oss.str() << endl;
206 for(
auto integral :
Integral) oss << Fout(integral) << endl;
207 ofstream intg_out(job_dir+
"/integrals");
208 intg_out << oss.str() << endl;
220 cmd <<
"cd " << job_dir <<
" && kira " <<
KArgs <<
" --silent job.yaml >/dev/null 2>&1";
221 auto rc = system(cmd.str().c_str());
230 fn << job_dir <<
"/results/F/kira_integrals.kira";
234 for(
auto kv :
Shift) {
235 Symbol bi(
"b"+to_string(kv.first-1));
236 bMAP[bi] = kv.second;
240 map<ex,int,ex_is_less> flags;
244 for(
auto line : strvec) {
247 exR = exR.subs(bMAP);
248 Rules.append(exL==exR);
253 }
else if(is_zero(exL)) {
255 if(!exL.match(F(
w1,
w2))) {
256 cout << line << endl;
257 throw Error(
"KIRA::Import error found.");
264 exR = exR.subs(bMAP);
265 Rules.append(exL==exR);
270 for(
auto kv : flags) {
271 if(kv.second!=0)
MIntegral.append(kv.first);
274 find(exRs,F(
w1,
w2),miset);
275 for(
auto mi : miset)
MIntegral.append(mi);
class used to wrap error message
void Export() override
Export input data for KIRA.
void Import() override
import kira result
void Run() override
invoke kira program for reduction
class extended to GiNaC symbol class, represent a positive symbol
lst gather_symbols(const ex &e)
get all symbols from input expression
ex str2ex(const string &expr, symtab stab)
convert string to ex expression, using Parser internally
vector< string > file2strvec(string filename, bool skip_empty)
read file content to string vector
void string_replace_all(string &str, const string &from, const string &to)
string ex2str(const ex &expr)
convert ex to output string, the defalut printer format will be used
bool dir_exists(string dir)
int ex2int(ex num)
ex to integer
ex subs(const ex &e, init_list sl)