commit be275c871536e3e3d01ab74ab58b434a78e567da
parent 5ab2e85af5e33364f855be263e30ec5a48bedc13
Author: Bakar Chargeishvili <bakar@bcharge.de>
Date: Tue, 3 May 2022 09:47:05 +0200
Fix colors
Diffstat:
M | webs.c | | | 211 | ++++++++++++++++++++++++++++++++++++++++++++----------------------------------- |
1 file changed, 117 insertions(+), 94 deletions(-)
diff --git a/webs.c b/webs.c
@@ -24,6 +24,8 @@ typedef struct {
Vertex absorber;
} Link;
+static int nGraphs = 0;
+
void
generate_legs(char **init, size_t n_init, char **fin, size_t n_fin, size_t nLoops, Leg *Legs)
{
@@ -31,7 +33,7 @@ generate_legs(char **init, size_t n_init, char **fin, size_t n_fin, size_t nLoop
int isGluon = 0;
if (!strcmp("g", init[i]))
isGluon = 1;
- Vertex *Vertices = (Vertex*)ecalloc(nLoops+1, sizeof(Vertex));
+ Vertex *Vertices = (Vertex*)ecalloc(nLoops+2, sizeof(Vertex));
Vertices[0] = (Vertex){i+1,0};
Legs[i+1] = (Leg){init[i], 1, i, 0, isGluon, Vertices};
}
@@ -40,9 +42,9 @@ generate_legs(char **init, size_t n_init, char **fin, size_t n_fin, size_t nLoop
int isGluon = 0;
if (!strcmp("g", fin[i]))
isGluon = 1;
- Vertex *Vertices = (Vertex *)ecalloc(nLoops+1, sizeof(Vertex));
+ Vertex *Vertices = (Vertex *)ecalloc(nLoops+2, sizeof(Vertex));
Vertices[0] = (Vertex){n_init+i+1,0};
- Legs[n_init+i+1] = (Leg){init[i], 1, n_init+i, 0, isGluon,Vertices};
+ Legs[n_init+i+1] = (Leg){fin[i], 0, n_init+i, 0, isGluon,Vertices};
}
}
@@ -55,6 +57,8 @@ generate_vertices(Leg *Legs, size_t nLegs, int nLoops, Vertex *Vertices)
Vertices[j+nLoops*i] = (Vertex){i+1, 1+j};
Legs[i+1].Vertices[j+1] = Vertices[j+nLoops*i];
}
+ Vertex V = (Vertex){i+1,999};
+ Legs[i+1].Vertices[nLoops+1] = V;
}
/*
@@ -65,99 +69,44 @@ generate_vertices(Leg *Legs, size_t nLegs, int nLoops, Vertex *Vertices)
}
void
-generate_loops(Vertex *Vertices, Leg *Legs, Link *Graphs, size_t nVx, size_t nLegs, int nLoops, int nGenLoops)
+generate_loops(Vertex *Vertices, Leg *Legs, Link **Graphs, size_t nVx, size_t nLegs, int nLoops, int nGenLoops)
{
+ if (nGenLoops == nLoops) {
+ printf("End recursion.\n");
+ free(Vertices);
+ nGraphs++;
+ return;
+ }
for (int iVx = 0; iVx < nVx; ++iVx) {
Vertex V = Vertices[iVx];
- Vertex *targets = (Vertex*)ecalloc(nLegs-V.legId, sizeof(Vertex));
- printf("Target count: %ld\n", nLegs-V.legId);
- printf("V%d%d: ", V.legId, V.id);
+ size_t nTargets = nLegs-V.legId;
+ Vertex *targets = (Vertex*)ecalloc(nTargets, sizeof(Vertex));
+ int iTar = -1;
for (int iLeg = V.legId+1; iLeg <= nLegs; ++iLeg) {
- printf("%d ", iLeg);
+ /*printf("Leg %d\n", iLeg);*/
+ targets[++iTar] = Legs[iLeg].Vertices[V.id];
}
- printf("\n");
- /*
- Link *Graph = (Link *)ecalloc(nLoops, sizeof(Link));
- int iEdge = -1;
- for (int jVx = 0; jVx < nVx; ++jVx) {
- if (iVx == jVx) {
- continue;
- }
- Graph[++iEdge] = (Link){Vertices[iVx], Vertices[jVx]};
- printf("V%d%d\n", iVx, jVx);
+
+ for (int iTar = 0; iTar < nTargets; ++iTar) {
+ /*printf("cycle\n");*/
+ Vertex T = targets[iTar];
+ printf("Loop: %d\tV%d%d - V%d%d\n", nGenLoops, V.legId, V.id, T.legId, T.id);
+ Graphs[nGraphs][nGenLoops] = (Link){V,T};
+ /*
+ int i = 0;
+ int iGraph = nGraphs;
+ printf("Graph# %d\tV%d%d - V%d%d\n", iGraph, Graphs[iGraph][i].emitter.legId, Graphs[iGraph][i].emitter.id, Graphs[iGraph][i].absorber.legId, Graphs[iGraph][i].absorber.id);
+ */
+ //targets += 1;
+ nGenLoops++;
+ printf("nGenLoops %d\n", nGenLoops);
+ //generate_loops(targets, Legs, Graphs, nTargets-1, nLegs, nLoops, nGenLoops--);
+ Vertex *remainingVtcs = (Vertex *)ecalloc(nVx-1, sizeof(Vertex));
+ memmove(&remainingVtcs[0], &Vertices[1], (nVx - 1) * sizeof(Vertex));
+ generate_loops(remainingVtcs, Legs, Graphs, nTargets-1, nLegs, nLoops, nGenLoops--);
}
- */
}
- /* Find the first non-deleted vertex */
- //int mVx = -1;
- //for (int iVx=0; iVx<nVx; ++iVx) {
- //if (!deletedVertices[iVx]) {
- //mVx = iVx;
- //break;
- //}
- //}
- //printf("mVx %d\n", mVx);
-//
- //Vertex *AllPossConns = (Vertex *)ecalloc(nVx, sizeof(Vertex));
- //size_t nConns = 0;
- //for (int iVx=mVx; iVx<nVx; ++iVx) {
- //if (!deletedVertices[iVx] && Vertices[iVx].legId != Vertices[mVx].legId) {
- //AllPossConns[nConns++] = Vertices[iVx];
- //}
- //}
-//
- //if (nConns == 0 || mVx == -1) {
- //free(deletedVertices);
- //printf("End rec");
- //return;
- //}
-//
- ///* We build the connections here */
- //static int iGraph = 0;
- //for (int iVx = 0; iVx < nConns; ++iVx) {
- //if (!nGenLoops)
- //printf("yess");
- //Graphs[iGraph*nLoops+nGenLoops] = (Link){Vertices[mVx], AllPossConns[iVx]};
- //printf("V%d%d - V%d%d\n", Vertices[mVx].legId, Vertices[mVx].id, AllPossConns[iVx].legId, AllPossConns[iVx].id);
- ///* Gluon connection introduces new vertices.
- //* Gluon legId = (emitter legId + 100)
- //*/
-//
- ///*
- //for (int i = 0; i < nLoops-nGenLoops; ++i) {
- //AllPossConns[i] = (Vertex){Vertices[mVx].legId+100,i}
- //}
- //*/
-//
- //deletedVertices[mVx] = 1;
- //deletedVertices[AllPossConns[iVx].id] = 1;
- //nGenLoops++;
- //if(nGenLoops < nLoops) {
- //int *deletedCopy = (int *)ecalloc(nVx, sizeof(int));
- //deletedCopy[mVx] = 1;
- //deletedCopy[AllPossConns[iVx].id] = 1;
- //generate_loops(Vertices, deletedCopy, Graphs, nVx, nLoops, nGenLoops);
- //}
- //else if (nGenLoops == nLoops) {
- //iGraph++;
- //}
- //nGenLoops--;
- //}
- //free(AllPossConns);
-//
- ///*
- //for (int iVx=mVx+1; iVx<nVx; ++iVx)
- //deletedVertices[iVx] = 0;
- //*/
- ///*
- //printf("%d\n", nConns);
- //printf("%d\n", deletedVertices[mVx-1]);
- //printf("%d\n", deletedVertices[mVx]);
- //printf("%d\n", deletedVertices[mVx+1]);
- //*/
-//
//generate_loops(Vertices, deletedVertices, Graphs, nVx, nLoops, nGenLoops);
-//
////memmove(&AllPossVertices[0], &Vertices[1], (n_vx - 1) * sizeof(Vertex));
}
@@ -172,9 +121,12 @@ main(int argc, char *argv[])
die("usage: webs [-v]");
char *initial[] = {"g","g"};
+ //char *initial[] = {"q","qbar"};
+ //char *final[] = {"q","qbar"};
char *final[] = {"q","qbar", "g"};
+ //char *final[] = {"q","qbar", "q", "qbar", "q", "qbar","q", "qbar","q", "qbar","q","qbar", "q", "qbar", "q", "qbar","q", "qbar"};
- int nLoops = 2;
+ int nLoops = 1;
size_t nLegs = NELEMS(initial) + NELEMS(final);
Leg Legs[nLegs+1];
@@ -189,36 +141,107 @@ main(int argc, char *argv[])
}
/*int *deletedVertices = (int *)ecalloc(nVx, sizeof(int));*/
- Link *Graphs = (Link *)ecalloc(300*nLoops, sizeof(Link));
+ Link **Graphs = (Link **)ecalloc(300*nLoops, sizeof(Link*));
+ for (int i = 0; i < 300; ++i) {
+ Graphs[i] = (Link*)ecalloc(nLoops, sizeof(Link));
+ }
Link *Skeleton = (Link *)ecalloc(300*nLoops, sizeof(Link));
int iEdge = -1;
for (int iLeg = 1; iLeg <= nLegs; ++iLeg) {
Vertex* LegVertices = Legs[iLeg].Vertices;
Skeleton[++iEdge] = (Link){LegVertices[0],LegVertices[1]};
- for (int iVx = 1; iVx < nLoops; ++iVx) {
+ for (int iVx = 1; iVx <= nLoops; ++iVx) {
Skeleton[++iEdge] = (Link){LegVertices[iVx],LegVertices[iVx+1]};
}
/*printf("Last vx: V%d%d\n", LegVertices[nLoops].legId, LegVertices[nLoops].id);*/
- Skeleton[++iEdge] = (Link){LegVertices[nLoops], (Vertex){999, 999}};
+ //Skeleton[++iEdge] = (Link){LegVertices[nLoops], (Vertex){999, 999}};
}
- for (int i = 0; i < iEdge; ++i) {
- printf("Emit V%d%d Absorb V%d%d\n",
+ for (int i = 0; i <= iEdge; ++i) {
+ printf("Parton lines: Emit V%d%d Absorb V%d%d\n",
Skeleton[i].emitter.legId,Skeleton[i].emitter.id, Skeleton[i].absorber.legId,Skeleton[i].absorber.id);
}
printf("Edge count: %d\n", iEdge);
generate_loops(Vertices, Legs, Graphs, nVx, nLegs, nLoops, 0);
+ for (int iGraph=0; iGraph<nGraphs; ++iGraph) {
+ for (int i = 0; i < nLoops; ++i) {
+ printf("Graph# %d\tV%dx%d - V%dx%d\n", iGraph, Graphs[iGraph][i].emitter.legId, Graphs[iGraph][i].emitter.id, Graphs[iGraph][i].absorber.legId, Graphs[iGraph][i].absorber.id);
+ int emitterLegId = Graphs[iGraph][i].emitter.legId;
+ int emitterId = Graphs[iGraph][i].emitter.id;
+ Vertex *emitterVtcs = Legs[emitterLegId].Vertices;
+ int emitterNxtId = emitterVtcs[emitterId+1].id;
+
+ int absorberLegId = Graphs[iGraph][i].absorber.legId;
+ int absorberId = Graphs[iGraph][i].absorber.id;
+ Vertex *absorberVtcs = Legs[absorberLegId].Vertices;
+ int absorberNxtId = absorberVtcs[absorberId+1].id;
+
+ char *color = (char*)malloc(10000 * sizeof(char));
+ char *kin = (char*)malloc(10000 * sizeof(char));
+
+ if (Legs[emitterLegId].init && !strcmp(Legs[emitterLegId].name,"q")){
+ sprintf(color+strlen(color), "\tSUNT(Glu99,Col%d%d,Col%d)*",emitterLegId,emitterNxtId,emitterLegId);
+ sprintf(kin+strlen(kin), "\tv%d(n1)/(v%d.l)*",emitterLegId,emitterLegId);
+ }
+ else if (!Legs[emitterLegId].init && !strcmp(Legs[emitterLegId].name,"q")){
+ sprintf(color+strlen(color), "\tSUNT(Glu99,Col%d,Col%d%d)*",emitterLegId,emitterLegId,emitterNxtId);
+ }
+ else if (Legs[emitterLegId].init && !strcmp(Legs[emitterLegId].name,"qbar")){
+ sprintf(color+strlen(color), "\tSUNT(Glu99,Col%d,Col%d%d)*",emitterLegId,emitterLegId,emitterNxtId);
+ }
+ else if (!Legs[emitterLegId].init && !strcmp(Legs[emitterLegId].name,"qbar")){
+ sprintf(color+strlen(color), "\tSUNT(Glu99,Col%d%d,Col%d)*",emitterLegId,emitterNxtId,emitterLegId);
+ }
+
+ if (Legs[absorberLegId].init && !strcmp(Legs[absorberLegId].name,"q")){
+ sprintf(color+strlen(color), "SUNT(Glu99,Col%d%d,Col%d)*",absorberLegId,absorberNxtId,absorberLegId);
+ }
+ else if (!Legs[absorberLegId].init && !strcmp(Legs[absorberLegId].name,"q")){
+ sprintf(color+strlen(color), "SUNT(Glu99,Col%d,Col%d%d)*",absorberLegId,absorberLegId,absorberNxtId);
+ }
+ else if (Legs[absorberLegId].init && !strcmp(Legs[absorberLegId].name,"qbar")){
+ sprintf(color+strlen(color), "SUNT(Glu99,Col%d,Col%d%d)*",absorberLegId,absorberLegId,absorberNxtId);
+ }
+ else if (!Legs[absorberLegId].init && !strcmp(Legs[absorberLegId].name,"qbar")){
+ sprintf(color+strlen(color), "SUNT(Glu99,Col%d%d,Col%d)*",absorberLegId,absorberNxtId,absorberLegId);
+ }
+
+ if (Legs[emitterLegId].init && !strcmp(Legs[emitterLegId].name,"g")){
+ sprintf(color+strlen(color), "(-i_)*SUNF(Glu99,Glu%d,Glu%d%d)*",emitterLegId,emitterLegId,emitterNxtId);
+ }
+ else if (!Legs[emitterLegId].init && !strcmp(Legs[emitterLegId].name,"g")){
+ sprintf(color+strlen(color), "(-i_)*SUNF(Glu99,Glu%d%d,Glu%d)*",emitterLegId,emitterNxtId,emitterLegId);
+ }
+
+ if (Legs[absorberLegId].init && !strcmp(Legs[absorberLegId].name,"g")){
+ sprintf(color+strlen(color), "(-i_)*SUNF(Glu99,Glu%d,Glu%d%d)*",absorberLegId,absorberLegId,absorberNxtId);
+ }
+ else if (!Legs[absorberLegId].init && !strcmp(Legs[absorberLegId].name,"g")){
+ sprintf(color+strlen(color), "(-i_)*SUNF(Glu99,Glu%d%d,Glu%d)*",absorberLegId,absorberNxtId,absorberLegId);
+ }
+
+ for (int iLeg = 1; iLeg <= nLegs; ++iLeg) {
+ if (iLeg != emitterLegId && iLeg !=absorberLegId) {
+ sprintf(color+strlen(color), "d_(Col%d,Col%d%d)*",Legs[iLeg].Vertices[0].legId,Legs[iLeg].Vertices[0].legId,Legs[iLeg].Vertices[nLoops+1].id );
+ }
+ }
+ sprintf(color+strlen(color), "1;\n");
+ printf("%s\n", color);
+ }
+ }
return 0;
+ /*
for (int iVx=0; iVx<300; ++iVx) {
printf("Graph ID: %d\n",iVx);
for (int i=0; i<nLoops; ++i) {
printf("V%d%d-V%d%d\n",Graphs[iVx*nLoops+i].emitter.legId, Graphs[iVx*nLoops+i].emitter.id, Graphs[iVx*nLoops+i].absorber.legId, Graphs[iVx*nLoops+i].absorber.id);
}
}
+ */
//draw(Legs, Connections);