Beispiel #1
0
int8_t cmd_periodic(uint8_t argc, char **argv)
{
    periodic_func_t **funcp;
    periodic_func_t *func = NULL;
    bool enable;
    int8_t rc;

    if (argc != 1 && argc < 3) {
        OUT("usage: periodic [<func> +|- [<args>...]]\r\n");
        return NRK_ERROR;
    }
    
    funcp = &functions[0];
    while (*funcp) {
        if (argc == 1) {
            OUTF((*funcp)->name); OUT(" ");
        } else {
            if (!strcmp_P(argv[1], (*funcp)->name))
                break;
        }
        funcp++;
    }

    if (argc == 1) {
        OUT("\r\n");
        return NRK_OK;
    }

    if (!*funcp) {
        OUT("ERROR: func not found\r\n");
        return NRK_ERROR;
    }
    func = *funcp;

    enable = argv[2][0] == '+';

    if (enable && func->config) {
        rc = func->config(argc - 3, argc >= 3 ? &argv[3] : NULL);
        if (rc != NRK_OK) {
            LOG("config failed: func "); LOGF(func->name); LOGNL();
            return NRK_ERROR;
        }
    }
    func->enabled = enable;
    nrk_event_signal(func_signal);

    LOG("func enabled: "); LOGF(func->name);
    LOGP(" %d", func->enabled);
    LOGNL();

    return NRK_OK;
}
Beispiel #2
0
// main routine
int main(int argc, char **argv)
{
  // Define force-deformation relationship for spring

  // dummy specimen
  UniaxialMaterial *theMaterial1 = new ElasticMaterial(1, 5.0);
  UniaxialMaterial *theMaterial2 = new Steel01(2, 5.0, 5.0, 0.1);

    
  // set ctrlData, daqData
  int numMat = 2;
  /*
  ExperimentalCP **cCP = new ExperimentalCP* [2];
  ArrayOfTaggedObjects *ctrlData = new ArrayOfTaggedObjects(1);
  cCP[0] = new ExperimentalCP(1, 1, OF_Dir_X, OF_Resp_Disp);
  cCP[1] = new ExperimentalCP(2, 1, OF_Dir_X, OF_Resp_Vel);
  for(int i=0; i<2; i++) 
    ctrlData->addComponent(cCP[i]);

  ExperimentalCP **dCP = new ExperimentalCP* [3];
  ArrayOfTaggedObjects *daqData = new ArrayOfTaggedObjects(1);
  dCP[0] = new ExperimentalCP(1, 1, OF_Dir_X, OF_Resp_Disp);
  dCP[1] = new ExperimentalCP(2, 1, OF_Dir_X, OF_Resp_Force);
  dCP[2] = new ExperimentalCP(3, 1, OF_Dir_X, OF_Resp_Vel);
  for(int i=0; i<3; i++) 
    daqData->addComponent(dCP[i]);
  */
  ID sizeTrial(OF_Resp_All), sizeOut(OF_Resp_All);
//  ID sizeTrial(5), sizeOut(5);
  sizeTrial[0] = numMat;
  sizeTrial[1] = numMat;
  sizeOut[0] = numMat;
  sizeOut[1] = numMat;
  sizeOut[3] = numMat;
  
  // Define ExperimentalControl
  ECSimUniaxialMaterials *theController 
    = new ECSimUniaxialMaterials(1, sizeTrial, sizeOut);
  //    = new ECSimUniaxialMaterials(1, *ctrlData, *daqData);
  theController->addDummySpecimen(theMaterial1);
  theController->addDummySpecimen(theMaterial2);

  theController->setup();

  Vector *disp, *vel, *force;
  Vector *Tdisp, *Tvel;
  disp = new Vector(numMat);
  vel = new Vector(numMat);
  force = new Vector(numMat);
  Tdisp = new Vector(numMat);
  Tvel = new Vector(numMat);

  ofstream OUTD("outD.dat");
  ofstream OUTF("outF.dat");
  int i,j;
  for(i=0; i<100; i++) {
    for(j=0; j<numMat; j++) {
      (*Tdisp)[j] = 3.0*sin(2.*3.141592*i/100);
    }

    theController->setTrialResponse(Tdisp, Tvel, (Vector*)0, (Vector*)0, (Vector*)0);
    theController->getDaqResponse(disp, vel, (Vector*)0, force, (Vector*)0);

    opserr << "Tdisp = " << *Tdisp;
    opserr << "Tvel = " << *Tvel << endln;
    opserr << "disp = " << *disp;
    opserr << "vel = " << *vel;
    opserr << "force = " << *force << endln;

    for(j=0; j<numMat; j++) {
      OUTD << ' ' << (*disp)[j];
      OUTF << ' ' << (*force)[j];
    }
    OUTD << endln; OUTF << endln;

    theController->commitState();
  }

  return 0;
}	
Beispiel #3
0
void wilson_dslash_trick(double *outf, double *in0, double *in1, double *in2, double *in3, 
			 double sign, int accum)
{
  int c;

  if(accum == 0) {
    for(c=0;c<3;c++){
      /* trick into spin component 0*/
      OUTF(0,c,0) =          IN0(0,c,0) + IN1(0,c,0) + IN2(0,c,0) + IN3(0,c,0);
      OUTF(1,c,0) =          IN0(1,c,0) + IN1(1,c,0) + IN2(1,c,0) + IN3(1,c,0); 
      
      /* trick into spin component 1*/
      OUTF(0,c,1) =          IN0(0,c,1) + IN1(0,c,1) + IN2(0,c,1) + IN3(0,c,1); 
      OUTF(1,c,1) =          IN0(1,c,1) + IN1(1,c,1) + IN2(1,c,1) + IN3(1,c,1); 
      
      /* trick into spin component 2*/
      OUTF(0,c,2) = sign * ( IN0(1,c,1) + IN1(0,c,1) + IN2(1,c,0) + IN3(0,c,0) );
      OUTF(1,c,2) = sign * (-IN0(0,c,1) + IN1(1,c,1) - IN2(0,c,0) + IN3(1,c,0) );
      
      /* trick into spin component 3*/
      OUTF(0,c,3) = sign * ( IN0(1,c,0) - IN1(0,c,0) - IN2(1,c,1) + IN3(0,c,1) );
      OUTF(1,c,3) = sign * (-IN0(0,c,0) - IN1(1,c,0) + IN2(0,c,1) + IN3(1,c,1) );
    }

  } else {
    for(c=0;c<3;c++){
      /* trick and accumulate into spin component 0*/
      OUTF(0,c,0) = OUTF(0,c,0) +          IN0(0,c,0) + IN1(0,c,0) + IN2(0,c,0) + IN3(0,c,0);
      OUTF(1,c,0) = OUTF(1,c,0) +          IN0(1,c,0) + IN1(1,c,0) + IN2(1,c,0) + IN3(1,c,0); 
      
      /* trick and accumulate into spin component 1*/
      OUTF(0,c,1) = OUTF(0,c,1) +          IN0(0,c,1) + IN1(0,c,1) + IN2(0,c,1) + IN3(0,c,1); 
      OUTF(1,c,1) = OUTF(1,c,1) +          IN0(1,c,1) + IN1(1,c,1) + IN2(1,c,1) + IN3(1,c,1); 
      
      /* trick and accumulate into spin component 2*/
      OUTF(0,c,2) = OUTF(0,c,2) + sign * ( IN0(1,c,1) + IN1(0,c,1) + IN2(1,c,0) + IN3(0,c,0) );
      OUTF(1,c,2) = OUTF(1,c,2) + sign * (-IN0(0,c,1) + IN1(1,c,1) - IN2(0,c,0) + IN3(1,c,0) );
      
      /* trick and accumulate into spin component 3*/
      OUTF(0,c,3) = OUTF(0,c,3) + sign * ( IN0(1,c,0) - IN1(0,c,0) - IN2(1,c,1) + IN3(0,c,1) );
      OUTF(1,c,3) = OUTF(1,c,3) + sign * (-IN0(0,c,0) - IN1(1,c,0) + IN2(0,c,1) + IN3(1,c,1) );
    }

  }

}