81 if ( m->invertices >= m->sizevertices ) {
82 if ( m->sizevertices == 0 ) newsize = 20;
83 else newsize = 2*m->sizevertices;
84 new = (
VERTEX **)Malloc1(newsize*
sizeof(
VERTEX *),
"m->vertices");
85 for ( i = 0; i < m->sizevertices; i++ )
new[i] = m->vertices[i];
86 if ( m->sizevertices > 0 ) M_free(m->vertices,
"m->vertices");
88 m->sizevertices = newsize;
91 m->vertices[m->invertices++] = v;
106UBYTE *ReadParticle(UBYTE *s,
VERTEX *v,
MODEL *m,
int par)
109 PARTICLE *p = v->particles + v->nparticles++;
113 name = s; s = SkipName(s); c = *s; *s = 0;
114 if ( GetVar(name,&type,&funnum,CFUNCTION,NOAUTO) == NAMENOTFOUND ) {
115 p->number = AddFunction(name,0,VERTEXFUNCTION,0,0,0,-1,-1) + FUNCTION;
117 else if ( par == 1 && type == CFUNCTION && functions[funnum].spec == VERTEXFUNCTION ) {
118 p->number = funnum+FUNCTION;
120 else if ( par == 0 && type == CFUNCTION && functions[funnum].spec == VERTEXFUNCTION ) {
125 for ( i = 0; i < m->nparticles-1; i++ ) {
126 for ( j = 0; j < m->vertices[i]->nparticles; j++ ) {
127 if ( m->vertices[i]->particles[j].number == funnum ) {
128 MesPrint(
"&Illegal attempt to redefine a particle in the same model: %s",name);
133 p->number = funnum+FUNCTION;
136 MesPrint(
"&Name of particle previously declared as another variable: %s",name);
140 while ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) s++;
153 WORD numberofset, *e;
161 if ( AC.modelspace == 0 || AC.nummodels >= AC.modelspace ) {
162 int newspace = 2*AC.modelspace+2, i;
163 MODEL **models = (
MODEL **)Malloc1((
sizeof(
MODEL *))*newspace,
"AC.models");
164 for ( i = 0; i < AC.modelspace; i++ ) models[i] = AC.models[i];
165 if ( AC.models ) M_free(AC.models,
"AC.models");
166 AC.modelspace = newspace;
170 AC.models[AC.nummodels++] = m;
174 m->nparticles = m->nvertices = m->sizevertices = m->invertices = 0;
175 m->sizecouplings = 0;
180 if ( FG.cTable[*s] == 0 ) {
181 while ( FG.cTable[*s] <= 1 ) s++;
183 m->name = strDup1(name,
"Model name");
187 MesPrint(
"&Illegal option in model statement: %s",s);
192 m->name = strDup1((UBYTE *)
"---",
"Model name");
194 MesPrint(
"&Illegal name for model: %s",name);
200 if ( GetName(AC.varnames,m->name,&numberofset,NOAUTO) != NAMENOTFOUND ) {
201 MesPrint(
"&Name conflict with name %s of model",m->name);
204 numberofset = AddSet(name,0);
205 set = Sets + numberofset;
207 e = (WORD *)FromVarList(&AC.SetElementList);
210 AC.SetList.numtemp = AC.SetList.num;
211 AC.SetElementList.numtemp = AC.SetElementList.num;
213 for ( i = 0; i <= MAXLEGS; i++ ) m->legcouple[i] = 0;
224int CoParticle(UBYTE *s)
229 if ( AC.nummodels <= 0 ) {
230 MesPrint(
"&No open model for particle statement");
233 m = AC.models[AC.nummodels-1];
234 if ( m->nvertices > 0 ) {
235 MesPrint(
"&In a model description Particle statements should be before Vertex statements.");
241 s = ReadParticle(s,v,m,0);
242 v->particles[0].type = 1;
243 while ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) s++;
244 if ( v->error == 0 ) {
245 if ( FG.cTable[*s] == 0 ) {
246 s = ReadParticle(s,v,m,0);
247 v->particles[1].type = -1;
248 if ( v->particles[0].number == v->particles[1].number ) {
249 v->particles[0].type = 0;
250 v->particles[1].type = 0;
254 v->particles[1] = v->particles[0];
256 v->particles[0].type = 0;
257 v->particles[1].type = 0;
260 if ( v->error == 0 && ( *s ==
'+' || *s ==
'-' ) ) {
261 int x = 0, sign = ( *s ==
'-' ) ? -1: 1;
263 while ( FG.cTable[*s] == 1 ) { x = 10*x + *s++ -
'0'; }
266 MesPrint(
"&Spin goes by dimension of SU(2) representation. Zero is not allowed.");
268 else { v->particles[0].spin = v->particles[1].spin = sign*x; }
271 else if ( v->error == 0 ) {
272 v->particles[0].spin = v->particles[1].spin = 1;
273 v->particles[0].type = 0;
274 v->particles[1].type = 0;
279 while ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) s++;
280 while ( v->error == 0 && *s != 0 && FG.cTable[*s] == 0 ) {
282 while ( FG.cTable[*s] == 0 ) s++;
284 if ( StrICont(opt,(UBYTE *)
"external") == 0 ) { v->externonly = 1; }
286 MesPrint(
"&Unrecognized option %s in particle statement.",opt);
290 while ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) s++;
296 for ( i = 0; i < MAXPARTICLES; i++ ) v->couplings[i] = 0;
306int CoVertex(UBYTE *s)
312 if ( AC.ModelLevel <= 0 ) {
313 MesPrint(
"&No open model for vertex statement");
316 m = AC.models[AC.nummodels-1];
323 while ( *s && *s !=
':' ) {
324 if ( v->error == 0 ) {
325 s = ReadParticle(s,v,m,1);
326 if ( v->error ) m->error = 1;
329 while ( *s && *s !=
':' ) {
330 if ( *s ==
'[' ) { SKIPBRA1(s) }
331 else if ( *s ==
'(' ) { SKIPBRA3(s) }
332 else if ( *s == 0 ) {
334 MesPrint(
"&No coupling constant in vertex statement.");
341 if ( v->error == 0 ) {
345 if ( v->ncouplings >= 2*MAXCOUPLINGS ) {
346 MesPrint(
"&More than %d coupling constants in vertex.",(WORD)MAXCOUPLINGS);
347 MesPrint(
" Recompile with a larger value for MAXCOUPLINGS.");
350 ss = s; s = SkipName(s); c = *s; *s = 0; name = ConstructName(ss,0);
354 MesPrint(
"&Invalid coupling constant in vertex statement.");
356 if ( GetVar(name,&type,&v->couplings[v->ncouplings],CSYMBOL,WITHAUTO)
358 WORD minpow = -MAXPOWER;
359 WORD maxpow = MAXPOWER;
360 WORD cplx = 0, dim = 0;
361 v->couplings[v->ncouplings] = AddSymbol(name,minpow,maxpow,cplx,dim);
369 WORD x = 0; WORD sign = 1;
371 while ( *s ==
'-' || *s ==
'+' ) {
372 if ( *s ==
'-' ) sign = -sign;
377 MesPrint(
"&Invalid negative power of coupling constant.");
379 while ( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
380 v->couplings[v->ncouplings++] = x;
383 v->couplings[v->ncouplings++] = 1;
386 if ( *s ==
'*' ) { s++;
continue; }
387 if ( *s !=
',' )
break;
394 MesPrint(
"&A vertex statement needs at least one coupling constant.");
397 if ( v->error == 0 ) {
402 for ( i = 0; i < v->nparticles; i++ ) {
403 for ( j = 0; j < m->nparticles; j++ ) {
404 if ( m->vertices[j]->particles[0].number == v->particles[i].number )
break;
405 if ( m->vertices[j]->particles[1].number == v->particles[i].number )
break;
407 m->vertices[j]->couplings[v->nparticles] = 1;
418int CoEndModel(UBYTE *s)
421 WORD csize = 0, *newcouplings, newsize;
424 if ( AC.ModelLevel <= 0 ) {
425 MesPrint(
"&EndModel statement without matching Model statement");
428 m = AC.models[AC.nummodels-1];
435 for ( i = 0; i < m->nvertices; i++ ) {
436 v = m->vertices[i+m->nparticles];
437 m->legcouple[v->nparticles] = 1;
438 if ( m->ncouplings + v->ncouplings > csize ) {
439 if ( csize == 0 ) newsize = v->ncouplings + 10;
440 else newsize = 2*csize;
441 newcouplings = (WORD *)Malloc1(newsize*
sizeof(WORD),
"m->couplings");
442 for ( k = 0; k < m->ncouplings; k++ ) newcouplings[k] = m->couplings[k];
443 if ( csize > 0 ) M_free(m->couplings,
"m->couplings");
444 m->couplings = newcouplings;
447 for ( j = 0; j < v->ncouplings; j += 2 ) {
448 WORD sym = v->couplings[j];
449 for ( k = 0; k < m->ncouplings; k++ ) {
450 if ( sym == m->couplings[k] )
break;
451 if ( sym < m->couplings[k] ) {
452 for ( kk = m->ncouplings; kk > k; k-- )
453 m->couplings[kk] = m->couplings[kk-1];
454 m->couplings[k] = sym;
459 if ( k >= m->ncouplings ) m->couplings[m->ncouplings++] = sym;
464 return(LoadModel(m));