From 3f0510629e422e979b57d3f93791937912a4183a Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Tue, 14 Jun 2022 09:26:07 +0200 Subject: Update to v1.5. The update to version 1.5 is rather substantial, and introduces some minor backward-incompatibilities: * The header "#!symbols" has been replaced by "#!virtual_fields" * Multiplying polynomials using the '*' symbol is no longer supported (or, rather, the symbolic capabilities of meankondo were enhanced, and the syntax has been changed). * 'meantools exp' has been removed (its functionality is now handled by other means) * 'meantoolds derive' has been replaced by 'meantools differentiate' * The symbolic capabilities were enhanced: polynomials can now be multiplied, added, exponentiated, and their logarithms can be taken directly in the configuration file. * The flow equation can now be processed after being computed using the various "#!postprocess_*" entries. * Deprecated kondo_preprocess. * Compute the mean using an LU decomposition if possible. * More detailed checks for syntax errors in configuration file. * Check that different '#!group' entries are indeed uncorrelated. * New flags in meankondo: '-p' and '-A'. * New tool: meantools expand. * Improve conversion to LaTeX using meantools-convert * Assign terms randomly to different threads. * Created vim files to implement syntax highlighting for configuration files. * Multiple bug fixes --- src/meankondo.c | 213 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 167 insertions(+), 46 deletions(-) (limited to 'src/meankondo.c') diff --git a/src/meankondo.c b/src/meankondo.c index 1c976d4..8b5c197 100644 --- a/src/meankondo.c +++ b/src/meankondo.c @@ -1,5 +1,5 @@ /* -Copyright 2015 Ian Jauslin +Copyright 2015-2022 Ian Jauslin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ limitations under the License. /* meankondo -A simple tool to compute the renormalization group flow for Fermionic hierarchical models +A tool to compute the renormalization group flow for Fermionic hierarchical models */ @@ -49,15 +49,19 @@ A simple tool to compute the renormalization group flow for Fermionic hierarchic #include "mean.h" // various string operations #include "istring.h" +// symbolic trees +# include "tree.h" // read cli arguments int read_args_meankondo(int argc,const char* argv[], Str_Array* str_args, Meankondo_Options* opts); // print usage message int print_usage_meankondo(); +// check consistency of options +int check_meankondo_opts(Meankondo_Options opts); // compute flow int compute_flow(Str_Array str_args, Meankondo_Options opts); -// compute the flow equation -int compute_flow_equation(Polynomial init_poly, Id_Table idtable, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, Grouped_Polynomial* flow_equation); +// compute average +int compute_average(Polynomial init_poly, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, int print_progress, Polynomial* exp_poly); int main (int argc, const char* argv[]){ @@ -69,6 +73,9 @@ int main (int argc, const char* argv[]){ // read command-line arguments read_args_meankondo(argc,argv,&str_args,&opts); + // check command-line arguments + check_meankondo_opts(opts); + // warning message if representing rational numbers as floats #ifdef RATIONAL_AS_FLOAT fprintf(stderr,"info: representing rational numbers using floats\n"); @@ -101,6 +108,10 @@ int read_args_meankondo(int argc,const char* argv[], Str_Array* str_args, Meanko (*opts).threads=1; // do not chain (*opts).chain=0; + // do not print progress + (*opts).print_progress=0; + // print the flow equation + (*opts).group_poly=1; // loop over arguments for(i=1;i\n\n"); + printf("\nusage:\n meankondo [-t threads] [-C] [-p] [-A] \n\n"); + return(0); +} + +// check consistency of options +int check_meankondo_opts(Meankondo_Options opts){ + if(opts.chain==1 && opts.group_poly==0){ + fprintf(stderr,"aborting: the '-C' and '-A' options are incompatible\n"); + exit(-1); + } return(0); } @@ -163,6 +190,8 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){ Fields_Table fields; // their propagator Polynomial_Matrix propagator; + // preprocessor variables + Variables variables; // initial polynomial Polynomial init_poly; // list of rccs @@ -171,6 +200,8 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){ Groups groups; // flow equation Grouped_Polynomial flow_equation; + // polynomial produced by the averaging operation + Polynomial exp_poly; // parse fields @@ -183,29 +214,38 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){ parse_input_fields(str_args.strs[arg_index],&fields); } - // parse id table - arg_index=find_str_arg("id_table", str_args); - if(arg_index<0){ - fprintf(stderr,"error: no id table entry in the configuration file\n"); - exit(-1); + // parse variables + // must precede id_table, virtual_fields, identities and input_polynomial + arg_index=find_str_arg("preprocessor_variables", str_args); + if(arg_index>=0){ + parse_input_variables(str_args.strs[arg_index],&variables); } else{ - parse_input_id_table(str_args.strs[arg_index],&idtable, fields); + init_Variables(&variables,1); } - // parse symbols - arg_index=find_str_arg("symbols", str_args); - if(arg_index>=0){ - parse_input_symbols(str_args.strs[arg_index],&fields); + // parse id table + if(opts.group_poly==1){ + arg_index=find_str_arg("id_table", str_args); + if(arg_index<0){ + fprintf(stderr,"error: no id table entry in the configuration file\n"); + exit(-1); + } + else{ + parse_input_id_table(str_args.strs[arg_index],&idtable, fields, variables); + } } - else{ - init_Symbols(&(fields.symbols),1); + + // parse virtual_fields + arg_index=find_str_arg("virtual_fields", str_args); + if(arg_index>=0){ + parse_input_virtual_fields(str_args.strs[arg_index], &fields, variables); } // parse input polynomial arg_index=find_str_arg("input_polynomial", str_args); if(arg_index>=0){ - parse_input_polynomial(str_args.strs[arg_index],&init_poly, fields); + parse_input_polynomial(str_args.strs[arg_index],&init_poly, fields, variables); } else{ fprintf(stderr,"error: no input polynomial entry in the configuration file\n"); @@ -225,41 +265,90 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){ // parse identities arg_index=find_str_arg("identities", str_args); if(arg_index>=0){ - parse_input_identities(str_args.strs[arg_index],&fields); - } - else{ - init_Identities(&(fields.ids),1); + parse_input_identities(str_args.strs[arg_index],&fields, variables); } - // parse groups + // parse groups (must come after virtual_fields and propagator) arg_index=find_str_arg("groups", str_args); if(arg_index>=0){ - parse_input_groups(str_args.strs[arg_index],&groups); + parse_input_groups(str_args.strs[arg_index],&groups, propagator, fields); } else{ init_Groups(&groups, 1); } - // flow equation - compute_flow_equation(init_poly, idtable, fields, propagator, groups, opts.threads, &flow_equation); + // compute the average + compute_average(init_poly, fields, propagator, groups, opts.threads, opts.print_progress, &exp_poly); + free_Polynomial(init_poly); free_Polynomial_Matrix(propagator); - free_Fields_Table(fields); free_Groups(groups); + // parse postprocessing entry + arg_index=find_str_arg("postprocess_operation", str_args); + if(arg_index>=0){ + add_polynomial_to_variables("OUT", exp_poly, &variables); + // parse postprocess entry + Polynomial postprocess_operation; + parse_input_polynomial(str_args.strs[arg_index], &postprocess_operation, fields, variables); + // replace exp_poly + free_Polynomial(exp_poly); + exp_poly=postprocess_operation; + } + + if(opts.group_poly==1){ + // flow equation + group_polynomial(exp_poly, &flow_equation, idtable, fields); + } + + // postprocess flow equation + arg_index=find_str_arg("postprocess_flow_equation", str_args); + if(arg_index>=0){ + Polynomial flow_polynomial; + // polynomial made of the rcc's multiplied by the corresponding fields (parsed from idtable) + idtable_to_polynomial(idtable, &flow_polynomial); + + // add to variables + add_polynomial_to_variables("FLOW", flow_polynomial, &variables); + free_Polynomial(flow_polynomial); + + // parse postprocess entry + Polynomial postprocess_polynomial; + parse_input_polynomial(str_args.strs[arg_index], &postprocess_polynomial, fields, variables); + + // convert to flow equation + Grouped_Polynomial postprocess_flow_equation; + group_polynomial(postprocess_polynomial, &postprocess_flow_equation, idtable, fields); + free_Polynomial(postprocess_polynomial); + + // apply postprocessing to flow equation + Grouped_Polynomial new_flow; + compose_flow_equations(postprocess_flow_equation, flow_equation, &new_flow); + free_Grouped_Polynomial(postprocess_flow_equation); + + // replace flow_equation + free_Grouped_Polynomial(flow_equation); + flow_equation=new_flow; + } + + // if chain then print config file if(opts.chain==1){ for(i=0;i=0){ + Polynomial rcc_polynomial; + // polynomial made of the rcc's multiplied by the corresponding fields (parsed from idtable) + idtable_to_polynomial(idtable, &rcc_polynomial); + + // add to variables + add_polynomial_to_variables("RCC", rcc_polynomial, &variables); + free_Polynomial(rcc_polynomial); + + // parse postprocess entry + Polynomial numerical_postprocess_operation; + parse_input_polynomial(str_args.strs[arg_index], &numerical_postprocess_operation, fields, variables); + + // convert to flow equation + Grouped_Polynomial numerical_postprocess_flow_equation; + group_polynomial(numerical_postprocess_operation, &numerical_postprocess_flow_equation, idtable, fields); + free_Polynomial(numerical_postprocess_operation); + + // print postprocessing flow equation + printf("\n&\n#!postprocess_operation\n"); + grouped_polynomial_print(numerical_postprocess_flow_equation,'%','%'); + free_Grouped_Polynomial(numerical_postprocess_flow_equation); + } + + if(opts.group_poly==1){ + free_Id_Table(idtable); + } + free_Fields_Table(fields); + free_Variables(variables); + return(0); } -// compute the flow equation -int compute_flow_equation(Polynomial init_poly, Id_Table idtable, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, Grouped_Polynomial* flow_equation){ - // expectation - Polynomial exp_poly; - - polynomial_cpy(init_poly,&exp_poly); +// compute average +int compute_average(Polynomial init_poly, Fields_Table fields, Polynomial_Matrix propagator, Groups groups, int threads, int print_progress, Polynomial* exp_poly){ + polynomial_cpy(init_poly,exp_poly); // average if(threads>1){ - polynomial_mean_multithread(&exp_poly, fields, propagator, groups, threads); + polynomial_mean_multithread(exp_poly, fields, propagator, groups, threads, print_progress); } else{ - polynomial_mean(&exp_poly, fields, propagator, groups); + polynomial_mean(exp_poly, fields, propagator, groups, print_progress); } - - // grouped representation of expanded_poly - group_polynomial(exp_poly,flow_equation,idtable, fields); - free_Polynomial(exp_poly); - return(0); } -- cgit v1.2.3-70-g09d2