Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <ian@jauslin.org>2022-06-14 09:26:07 +0200
committerIan Jauslin <ian@jauslin.org>2022-06-14 09:46:36 +0200
commit3f0510629e422e979b57d3f93791937912a4183a (patch)
treebf2589b2689044261b0cd4d9e6b3082194fdd9e9 /src/meankondo.c
parent469bdc80712dbf9c12562059dc4594620b59a076 (diff)
Update to v1.5.HEADmaster
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
Diffstat (limited to 'src/meankondo.c')
-rw-r--r--src/meankondo.c213
1 files changed, 167 insertions, 46 deletions
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<argc;i++){
@@ -116,6 +127,13 @@ int read_args_meankondo(int argc,const char* argv[], Str_Array* str_args, Meanko
case 'C':
(*opts).chain=1;
break;
+ // print progress
+ case 'p':
+ (*opts).print_progress=1;
+ break;
+ case 'A':
+ (*opts).group_poly=0;
+ break;
// print version
case 'v':
printf("meankondo " VERSION "\n");
@@ -147,7 +165,16 @@ int read_args_meankondo(int argc,const char* argv[], Str_Array* str_args, Meanko
// print usage message
int print_usage_meankondo(){
- printf("\nusage:\n meankondo [-t threads] [-C] <filename>\n\n");
+ printf("\nusage:\n meankondo [-t threads] [-C] [-p] [-A] <filename>\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<str_args.length;i++){
// check whether to print the str_arg
get_str_arg_title(str_args.strs[i], &arg_header);
if (\
- str_cmp(arg_header.str, "symbols")==0 &&\
+ str_cmp(arg_header.str, "variables")==0 &&\
+ str_cmp(arg_header.str, "virtual_fields")==0 &&\
str_cmp(arg_header.str, "groups")==0 &&\
str_cmp(arg_header.str, "fields")==0 &&\
str_cmp(arg_header.str, "identities")==0 &&\
str_cmp(arg_header.str, "propagator")==0 &&\
str_cmp(arg_header.str, "input_polynomial")==0 &&\
- str_cmp(arg_header.str, "id_table")==0 ){
+ str_cmp(arg_header.str, "id_table")==0 &&\
+ str_cmp(arg_header.str, "postprocess_operation")==0 &&\
+ str_cmp(arg_header.str, "numerical_postprocess_operation")==0
+ ){
printf("%s\n&\n",str_args.strs[i].str);
}
free_Char_Array(arg_header);
@@ -268,34 +357,66 @@ int compute_flow(Str_Array str_args, Meankondo_Options opts){
printf("#!flow_equation\n");
}
- // print flow equation
- grouped_polynomial_print(flow_equation,'%','%');
+ // print result
+ if(opts.group_poly==1){
+ grouped_polynomial_print(flow_equation,'%','%');
+
+ // free memory
+ free_Grouped_Polynomial(flow_equation);
+ }
+ else{
+ polynomial_print(exp_poly);
+ }
// free memory
- free_Id_Table(idtable);
- free_Grouped_Polynomial(flow_equation);
+ free_Polynomial(exp_poly);
+
+ // parse numerical_postprocessing entry
+ arg_index=find_str_arg("numerical_postprocess_operation", str_args);
+ if(arg_index>=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);
}