static void VecNormalize( short scale, float dx, float dy, struct xycoord * vect ) /*================================================================================ Normalize the vector (dx,dy) to scale and return in vect. */ { float factor; factor = (float) scale / sqrtf( dx * dx + dy * dy ); vect->xcoord = dx * factor + roundoff( dx ); /* round result */ vect->ycoord = dy * factor + roundoff( dy ); }
short _WtoPhysX( double x ) /*========================= Map x from window coordinates to physical coordinates. */ { float phys_x; phys_x = ( (float) x - _Window.xleft ) * XScale1; phys_x += roundoff( phys_x ); return( (short) phys_x + _CurrState->clip.xmin ); }
int eval_rate (int sample_rate_factor, /* Fixed data hdr sample rate factor. */ int sample_rate_mult) /* Fixed data hdr sample rate multiplier*/ { double drate; int rate; if (sample_rate_factor > 0 && sample_rate_mult > 0) drate = (double)sample_rate_factor * (double)sample_rate_mult; else if (sample_rate_factor > 0 && sample_rate_mult < 0) drate = -1. * (double)sample_rate_factor / (double)sample_rate_mult; else if (sample_rate_factor < 0 && sample_rate_mult > 0) drate = -1. * (double)sample_rate_mult / (double)sample_rate_factor; else if (sample_rate_factor < 0 && sample_rate_mult < 0) drate = (double)sample_rate_mult / (double)sample_rate_factor; else drate = 0.; if (drate == 0.) rate = 0; else if (drate >= 1.) rate = roundoff(drate); else rate = -1 * roundoff(1./drate); return (rate); }
int main(void) { double student[MAXS]; double average; int n; while (scanf("%d", &n) && n != 0) { average = roundoff(input(student, n)); printf("$%.2f\n", exchange(student, average, n)); } return 0; }
short _WtoPhysY( double y ) /*========================= Map y from window coordinates to physical coordinates. */ { float phys_y; if( _Window.invert ) { phys_y = ( _Window.ytop - (float) y ) * YScale1; } else { phys_y = ( (float) y - _Window.ytop ) * YScale1; } phys_y += roundoff( phys_y ); return( (short) phys_y + _CurrState->clip.ymin ); }
int add_required_miniseed_blockettes (DATA_HDR *hdr) /* ptr to DATA_HDR. */ { int status = 0; /* Currently only blockette 1000 is required for miniSEED. */ if (my_wordorder < 0) get_my_wordorder(); if (find_blockette(hdr, 1000) == NULL) { BLOCKETTE_1000 b1000; int ok; b1000.hdr.type = 1000; b1000.hdr.next = 0; b1000.format = hdr->data_type; b1000.word_order = SEED_BIG_ENDIAN; b1000.data_rec_len = roundoff(log2((double)hdr->blksize)); b1000.reserved = 0; ok = add_blockette (hdr, (char *)&b1000, 1000, sizeof(BLOCKETTE_1000), my_wordorder, 0); if (! ok) status = MS_ERROR; } return (status); }
void settingsinput(int32_t *bands, int32_t samplecount, int32_t *samplerate, double *basefreq, double maxfreq, double *pixpersec, double *bandsperoctave, int32_t Xsize, int32_t mode) { /* mode : * 0 = Analysis mode * 1 = Synthesis mode */ int32_t i; double gf, f, trash; double ma; // maximum allowed frequency FILE *freqcfg; char byte; int32_t unset=0, set_min=0, set_max=0, set_bpo=0, set_y=0; // count of unset interdependant settings int32_t set_pps=0, set_x=0; size_t filesize; // boolean indicating if the configuration file's last expected byte is there (to verify the file's integrity) char conf_path[FILENAME_MAX]; // Path to the configuration file (only used on non-Windows platforms) #ifdef DEBUG printf("settingsinput...\n"); #endif #ifdef WIN32 freqcfg=fopen("arss.conf", "rb"); // open saved settings file #else sprintf(conf_path, "%s/%s", getenv("HOME"), ".arss.conf"); freqcfg=fopen(conf_path, "rb"); #endif if (*samplerate==0) // if we're in synthesis mode and that no samplerate has been defined yet { if (quiet==1) { fprintf(stderr, "Please provide a sample rate for your output sound.\nUse --sample-rate (-r).\nExiting with error.\n"); exit(EXIT_FAILURE); } //********Output settings querying******** printf("Sample rate [44100] : "); // Query for a samplerate *samplerate=getfloat(); if (*samplerate==0 || *samplerate<-2147483647) // The -2147483647 check is used for the sake of compatibility with C90 *samplerate = 44100; // Default value //--------Output settings querying-------- } if (*basefreq!=0) set_min=1; // count unset interdependant frequency-domain settings if (maxfreq!=0) set_max=1; if (*bandsperoctave!=0) set_bpo=1; if (*bands!=0) set_y=1; unset = set_min + set_max + set_bpo + set_y; if (unset==4) // if too many settings are set { if (mode==0) fprintf(stderr, "You have set one parameter too many.\nUnset either --min-freq (-min), --max-freq (-max), --bpo (-b)\nExiting with error.\n"); if (mode==1) fprintf(stderr, "You have set one parameter too many.\nUnset either --min-freq (-min), --max-freq (-max), --bpo (-b) or --height (-y)\nExiting with error.\n"); exit(EXIT_FAILURE); } if (*pixpersec!=0) set_pps=1; if (Xsize!=0) set_x=1; if (set_x+set_pps==2 && mode==0) { fprintf(stderr, "You cannot define both the image width and the horizontal resolution.\nUnset either --pps (-p) or --width (-x)\nExiting with error.\n"); exit(EXIT_FAILURE); } if (freqcfg) // load settings from file if it exists { for (i=0; i<(int32_t) (4*sizeof(double)); i++) filesize=fread(&byte, sizeof(char), 1, freqcfg); // verify the file's length rewind(freqcfg); } if (filesize==1) // if the file is at least as long as expected { if (*basefreq==0) fread(basefreq, sizeof(double), 1, freqcfg); // load values from it if they haven't been set yet else fread(&trash, sizeof(double), 1, freqcfg); if (maxfreq==0) fread(&maxfreq, sizeof(double), 1, freqcfg); // unless we have enough of them (unset==3) else fread(&trash, sizeof(double), 1, freqcfg); if (*bandsperoctave==0) fread(bandsperoctave, sizeof(double), 1, freqcfg); else fread(&trash, sizeof(double), 1, freqcfg); if (*pixpersec==0) fread(pixpersec, sizeof(double), 1, freqcfg); else fread(&trash, sizeof(double), 1, freqcfg); } else { if (*basefreq==0) *basefreq=27.5; // otherwise load default values if (maxfreq==0) maxfreq=20000; if (*bandsperoctave==0) *bandsperoctave=12; if (*pixpersec==0) *pixpersec=150; } if (freqcfg) fclose(freqcfg); if (unset<3 && set_min==0) { if (quiet==1) { fprintf(stderr, "Please define a minimum frequency.\nUse --min-freq (-min).\nExiting with error.\n"); exit(EXIT_FAILURE); } printf("Min. frequency (Hz) [%.3f]: ", *basefreq); gf=getfloat(); if (gf != 0) *basefreq=gf; unset++; set_min=1; } *basefreq /= *samplerate; // turn basefreq from Hz to fractions of samplerate if (unset<3 && set_bpo==0) { if (quiet==1) { fprintf(stderr, "Please define a bands per octave setting.\nUse --bpo (-b).\nExiting with error.\n"); exit(EXIT_FAILURE); } printf("Bands per octave [%.3f]: ", *bandsperoctave); gf=getfloat(); if (gf != 0) *bandsperoctave=gf; unset++; set_bpo=1; } if (unset<3 && set_max==0) { i=0; do { i++; f=*basefreq * pow(LOGBASE, (i / *bandsperoctave)); } while (f<0.5); ma=*basefreq * pow(LOGBASE, ((i-2) / *bandsperoctave)) * *samplerate; // max allowed frequency if (maxfreq > ma) if (myfmod(ma, 1.0) == 0.0) maxfreq = ma; // replaces the "Upper frequency limit above Nyquist frequency" warning else maxfreq = ma - myfmod(ma, 1.0); if (mode==0) // if we're in Analysis mode { if (quiet==1) { fprintf(stderr, "Please define a maximum frequency.\nUse --max-freq (-max).\nExiting with error.\n"); exit(EXIT_FAILURE); } printf("Max. frequency (Hz) (up to %.3f) [%.3f]: ", ma, maxfreq); gf=getfloat(); if (gf != 0) maxfreq=gf; if (maxfreq > ma) if (myfmod(ma, 1.0) == 0.0) maxfreq = ma; // replaces the "Upper frequency limit above Nyquist frequency" warning else maxfreq = ma - myfmod(ma, 1.0); } unset++; set_max=1; } if (set_min==0) { *basefreq = pow(LOGBASE, (*bands-1) / *bandsperoctave) * maxfreq; // calculate the lower frequency in Hz printf("Min. frequency : %.3f Hz\n", *basefreq); *basefreq /= *samplerate; } if (set_max==0) { maxfreq = pow(LOGBASE, (*bands-1) / *bandsperoctave) * (*basefreq * *samplerate); // calculate the upper frequency in Hz printf("Max. frequency : %.3f Hz\n", maxfreq); } if (set_y==0) { *bands = 1 + roundoff(*bandsperoctave * (log_b(maxfreq) - log_b(*basefreq * *samplerate))); printf("Bands : %d\n", *bands); } if (set_bpo==0) { if (LOGBASE==1.0) *bandsperoctave = maxfreq / *samplerate; else *bandsperoctave = (*bands-1) / (log_b(maxfreq) - log_b(*basefreq * *samplerate)); printf("Bands per octave : %.3f\n", *bandsperoctave); } if (set_x==1 && mode==0) // If we're in Analysis mode and that X is set (by the user) { *pixpersec = (double) Xsize * (double) *samplerate / (double) samplecount; // calculate pixpersec printf("Pixels per second : %.3f\n", *pixpersec); } if ((mode==0 && set_x==0 && set_pps==0) || (mode==1 && set_pps==0)) // If in Analysis mode none are set or pixpersec isn't set in Synthesis mode { if (quiet==1) { fprintf(stderr, "Please define a pixels per second setting.\nUse --pps (-p).\nExiting with error.\n"); exit(EXIT_FAILURE); } printf("Pixels per second [%.3f]: ", *pixpersec); gf=getfloat(); if (gf != 0) *pixpersec=gf; } *basefreq *= *samplerate; // turn back to Hz just for the sake of writing to the file #ifdef WIN32 freqcfg=fopen("arss.conf", "wb"); // saving settings to a file #else freqcfg=fopen(conf_path, "wb"); // saving settings to a file #endif if (freqcfg==NULL) { fprintf(stderr, "Cannot write to configuration file"); exit(EXIT_FAILURE); } fwrite(basefreq, sizeof(double), 1, freqcfg); fwrite(&maxfreq, sizeof(double), 1, freqcfg); fwrite(bandsperoctave, sizeof(double), 1, freqcfg); fwrite(pixpersec, sizeof(double), 1, freqcfg); fclose(freqcfg); *basefreq /= *samplerate; // basefreq is now in fraction of the sampling rate instead of Hz *pixpersec /= *samplerate; // pixpersec is now in fraction of the sampling rate instead of Hz }
pulsesequence() { // Define Variables and Objects and Get Parameter Values CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); DSEQ xdec = getdseq("X"); strncpy(xdec.t.ch,"obs",3); // These four statements assure strncpy(xdec.s.ch,"obs",3); // that the X decoupling will putCmd("chXtppm='obs'\n"); // be on X for either TPPM or putCmd("chXspinal='obs'\n"); // SPINAL. // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = 3.0*getval("pwH90") + getval("pwHtilt") + getval("tHX"); d.dutyoff = d1 + 4.0e-6 + getval("tHmix"); d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = getval("rd") + getval("ad") + at; d.c3 = d.c3 + (!strcmp(xdec.seq,"tppm")); d.c3 = d.c3 + ((!strcmp(xdec.seq,"tppm")) && (xdec.t.a > 0.0)); d.t3 = d2_; d.c4 = d.c4 + (!strcmp(xdec.seq,"spinal")); d.c4 = d.c4 + ((!strcmp(xdec.seq,"spinal")) && (xdec.s.a > 0.0)); d.t4 = d2_; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(phH90,16,table1); settable(phHmix1,16,table2); settable(phHmix2,4,table3); settable(phHtilt,4,table4); settable(phXhx,4,table5); settable(phHhx,4,table6); settable(phRec,4,table7); if (phase1 == 2) tsadd(phH90,1,4); setreceiver(phRec); // Begin Sequence txphase(phXhx); decphase(phH90); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H Preparation and tilt decrgpulse(getval("pwH90"),phH90,0.0,0.0); decunblank(); // Delay for 1H Wideline T2 _dseqon(xdec); delay(d2); _dseqoff(xdec); // Mix period for Spin Diffison decrgpulse(getval("pwH90"),phHmix1,0.0,0.0); delay(getval("tHmix")); decrgpulse(getval("pwH90"),phHmix2,0.0,0.0); // Tilt Pulse and Ramped H to X Cross Polarization with LG Offset decrgpulse(getval("pwHtilt"),phHtilt,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); // Begin Acquisition obsblank(); _blank34(); _dseqon(dec); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
pulsesequence() { // Define Variables and Objects and Get Parameter Values CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); MPSEQ c7 = getpostc7("c7X",0,0.0,0.0,0,1); MPSEQ c7ref = getpostc7("c7X",c7.iSuper,c7.phAccum,c7.phInt,1,1); strncpy(c7.ch,"obs",3); putCmd("chXc7='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwH90") + getval("tHX") + 2.0* getval("pwX90") + c7.t + c7ref.t; d.dutyoff = d1 + 4.0e-6 + 2.0*getval("tZF"); d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = d2_ + getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = d2_ + getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(phH90,4,table1); settable(phXhx,4,table2); settable(phHhx,4,table3); settable(phXmix1,4,table4); settable(phXmix2,4,table5); settable(phRec,4,table6); // Add STATES-TPPI (STATES + "FAD") double obsstep = 360.0/(PSD*8192); if (phase1 == 2) initval((45.0/obsstep),v1); else initval(0.0,v1); initval((d2*c7.of[0]*360.0/obsstep),v2); obsstepsize(obsstep); setreceiver(phRec); // Begin Sequence txphase(phXhx); decphase(phH90); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H to X Cross Polarization decrgpulse(getval("pwH90"),phH90,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); obspwrf(getval("aX90")); // Mixing with C7 Recoupling-Period One rgpulse(getval("pwX90"),phXmix1,0.0,0.0); obspwrf(getval("aXc7")); decoff(); xmtrphase(v1); txphase(phXmix1); delay(getval("tZF")); decpwrf(getval("aHmix")); decunblank(); decon(); _mpseq(c7, phXmix1); decoff(); // F1 Indirect Period For X xmtrphase(v2); txphase(phXmix2); _dseqon(dec); delay(d2); _dseqoff(dec); // Mixing with C7 Recoupling-Period Two decpwrf(getval("aHmix")); decunblank(); decon(); _mpseq(c7ref, phXmix2); decoff(); obspwrf(getval("aX90")); xmtrphase(zero); txphase(phXmix2); delay(getval("tZF")); rgpulse(getval("pwX90"),phXmix2,0.0,0.0); // Begin Acquisition _dseqon(dec); obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
void pulsesequence() { // Define Variables and Objects and Get Parameter Values MPSEQ fh = getfslg("fslgH",0,0.0,0.0,0,1); strncpy(fh.ch,"dec",3); putCmd("chHfslg='dec'\n"); double tHXhmqc = getval("tHXhmqc"); //parameters for hmqcHX implemented double pwHhxhmqc = getval("pwHhxhmqc"); //directly in the pulse sequence double pmHhxhmqc = getval("pmHhxhmqc"); double pwXhxhmqc = getval("pwXhxhmqc"); double aXhxhmqc = getval("aXhxhmqc"); double aHhxhmqc = getval("aHhxhmqc"); double d2init = getval("d2"); d2init = d2init - pwXhxhmqc; if (d2init < 0.0) d2init = 0.0; double d22 = d2init/2.0; CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwH90") + getval("tHX")+ 2.0*tHXhmqc + d2_ + 4.0*pmHhxhmqc + 2.0*pwHhxhmqc; d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(phH90,4,table1); settable(phXhx,4,table2); settable(phHhx,4,table3); settable(ph1Hhxhmqc,4,table4); settable(ph2Hhxhmqc,4,table5); settable(ph3Hhxhmqc,4,table6); settable(ph4Hhxhmqc,4,table7); settable(ph5Hhxhmqc,4,table8); settable(phXhxhmqc,32,table9); settable(ph6Hhxhmqc,4,table10); settable(ph7Hhxhmqc,8,table11); settable(ph8Hhxhmqc,4,table12); settable(ph9Hhxhmqc,4,table13); settable(phRec,16,table14); // Add STATES TPPI (States with FAD) tsadd(ph3Hhxhmqc,2*d2_index,4); tsadd(ph4Hhxhmqc,2*d2_index,4); tsadd(ph5Hhxhmqc,2*d2_index,4); tsadd(ph6Hhxhmqc,2*d2_index,4); tsadd(phRec,2*d2_index,4); if (phase1 == 2) { tsadd(ph3Hhxhmqc,1,4); tsadd(ph4Hhxhmqc,1,4); tsadd(ph5Hhxhmqc,1,4); tsadd(ph6Hhxhmqc,1,4); } setreceiver(phRec); // Begin Sequence txphase(phXhx); decphase(phH90); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H to X Cross Polarization decrgpulse(getval("pwH90"),phH90,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); // Begin hmqcHX with fh (FSLG) Between Pulses obspwrf(aXhxhmqc); _mpseqon(fh,ph1Hhxhmqc); // First "tau" period for J evolution delay(tHXhmqc); _mpseqoff(fh); decpwrf(aHhxhmqc); decrgpulse(pmHhxhmqc, ph2Hhxhmqc, 0.0, 0.0);// Create HX double-quantum coherence decrgpulse(pwHhxhmqc, ph3Hhxhmqc, 0.0, 0.0); decrgpulse(pmHhxhmqc, ph4Hhxhmqc, 0.0, 0.0); _mpseqon(fh,ph5Hhxhmqc); // Begin F1 evolution with FSLG delay(d22); rgpulse(pwXhxhmqc, phXhxhmqc, 0.0,0.0); delay(d22); _mpseqoff(fh); // End F1 evolution with FSLG decpwrf(aHhxhmqc); decrgpulse(pmHhxhmqc, ph6Hhxhmqc, 0.0, 0.0);// Refocus HX double quantum coherence decrgpulse(pwHhxhmqc, ph7Hhxhmqc, 0.0, 0.0); decrgpulse(pmHhxhmqc, ph8Hhxhmqc, 0.0, 0.0); _mpseqon(fh,ph9Hhxhmqc); // Second "tau" period for J evolution delay(tHXhmqc); _mpseqoff(fh); // Begin Acquisition decphase(phHhx); _dseqon(dec); obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
static void setup ( int32_t *img_height, int32_t samplecount, int32_t *wav_rate, double *low_freq, double *high_freq, double *pix_per_sec, double *bpo, int32_t img_width, int32_t mode ) { double f, ma; int32_t unset = 0, set_min = 0, set_max = 0, set_bpo = 0, set_y = 0, set_pps = 0, set_x = 0, i; if (*low_freq != 0) set_min = 1; if (*high_freq != 0) set_max = 1; if (*bpo != 0) set_bpo = 1; if (*img_height != 0) set_y = 1; unset = set_min + set_max + set_bpo + set_y; if (unset == 4) { message("%s", warn_1); message("%s", warn_2); *high_freq = 0.0; set_max = 0; } if (*pix_per_sec != 0) set_pps = 1; if (img_width != 0) set_x = 1; if (set_x + set_pps == 2 && mode == MODE_ANAL) { message("%s", warn_3); message("%s", warn_4); *pix_per_sec = 0.0; set_pps = 0; } *low_freq /= *wav_rate; if (unset < 3 && set_min == 0) { message("%s", err_21); exit(EXIT_FAILURE); } if (unset < 3 && set_bpo == 0) { message("%s", err_22); exit(EXIT_FAILURE); } if (unset < 3 && set_max == 0) { if (mode == MODE_ANAL) { message("%s", err_23); exit(EXIT_FAILURE); } i = 0; do { i++; f = *low_freq * pow(logbase, (i / *bpo)); } while (f < 0.5); ma = *low_freq * pow(logbase, ((i - 2) / *bpo)) * (*wav_rate); if (*high_freq > ma) { if (fmod(ma, 1.0) == 0.0) *high_freq = ma; else *high_freq = ma - fmod(ma, 1.0); } unset++; set_max = 1; } if (set_min == 0) { *low_freq = pow(logbase, (*img_height - 1) / *bpo) * (*high_freq); message("Minimum frequency set to: %.3f Hz", *low_freq); *low_freq /= *wav_rate; } if (set_max == 0) { *high_freq = pow(logbase, (*img_height - 1) / *bpo) * (*low_freq * (*wav_rate)); message("Maximum frequency set to: %.3f Hz", *high_freq); } if (set_y == 0) { *img_height = 1 + roundoff(*bpo * (log_b(*high_freq) - log_b(*low_freq * *wav_rate))); message("Image height set to: %d", *img_height); } if (set_bpo == 0) { if (logbase == 1.0) *bpo = *high_freq / *wav_rate; else *bpo = (*img_height - 1) / (log_b(*high_freq) - log_b(*low_freq * (*wav_rate))); message("Bands per octave set to: %.3f", *bpo); } if (set_x == 1 && mode == MODE_ANAL) { *pix_per_sec = (double) img_width * (double) *wav_rate / (double) samplecount; set_pps = 1; message("Pixels per second set to: %.3f", *pix_per_sec); } if ( (mode == MODE_ANAL && set_x == 0 && set_pps == 0) || (mode == MODE_SINE_SYNTH && set_pps == 0) ) { message("%s", err_24); exit(EXIT_FAILURE); } *pix_per_sec /= *wav_rate; }
void pulsesequence() { // Set the Maximum Dynamic Table and v-var Numbers settablenumber(20); setvvarnumber(30); // Define Variables and Objects and Get Parameter Values MPSEQ dumbo = getdumbogen("dumboX","dcf1X",0,0.0,0.0,0,1); strncpy(dumbo.ch,"obs",3); putCmd("chXdumbo='obs'\n"); MPSEQ c7 = getpostc7("c7X",0,0.0,0.0,0,1); MPSEQ c7ref = getpostc7("c7X",c7.iSuper,c7.phAccum,c7.phInt,1,1); strncpy(c7.ch,"obs",3); putCmd("chXc7='obs'\n"); WMPA wdumbo = getwdumbogen("wdumboX","dcfX"); strncpy(wdumbo.ch,"obs",3); putCmd("chXwdumbo='obs'\n"); double tXzfinit = getval("tXzf"); //Define the Z-filter delay in the sequence double tXzf = tXzfinit - 5.0e-6 - wdumbo.r1; // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = c7.t + getval("pwXtilt") + d2_ + getval("pwXtilt") + c7ref.t + getval("pwX90") + + wdumbo.q*wdumbo.cycles*wdumbo.pw; d.dutyoff = 4.0e-6 + d1 + tXzfinit + wdumbo.r2 + at - wdumbo.q*wdumbo.cycles*wdumbo.pw; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(ph1Xc7,4,table1); settable(phXdumbo,4,table2); settable(ph2Xc7,4,table3); settable(phX90,16,table4); settable(phXwdumbo,4,table5); settable(phRec,16,table6); settable(ph1Xtilt,4,table7); settable(ph2Xtilt,4,table8); // Set the Small-Angle Prep Phase double obsstep = 360.0/(PSD*8192); obsstepsize(obsstep); int phfX90 = initphase(0.0, obsstep); //Add STATES Quadrature Phase if (phase1 == 2) initval((45.0/obsstep),v1); else initval(0.0,v1); initval((d2*c7.of[0]*360.0/obsstep),v2); initval(0.0,v3); obsstepsize(obsstep); setreceiver(phRec); // Begin Sequence xmtrphase(v1); txphase(ph1Xc7); obspwrf(getval("aXc7")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // C7 Recoupling of 2Q coherence _mpseq(c7, ph1Xc7); // F1 Evolution With DUMBO xmtrphase(v3); if (!getval("scXdcf1")){ obspwrf(getval("aX90")); rgpulse(getval("pwXtilt"),ph1Xtilt,0.0,0.0); } obspwrf(getval("aXdumbo")); obsunblank(); _mpseqon(dumbo,phXdumbo); delay(d2); _mpseqoff(dumbo); if (!getval("scXdcf1")){ obspwrf(getval("aX90")); rgpulse(getval("pwXtilt"),ph2Xtilt,0.0,0.0); } obspwrf(getval("aX90")); obsunblank(); // C7 Transfer to 1Q Coherence xmtrphase(v2); _mpseq(c7ref, ph2Xc7); // Z-filter Delay delay(tXzf); // Detection Pulse txphase(phX90); obspwrf(getval("aX90")); startacq(5.0e-6); rcvroff(); delay(wdumbo.r1); rgpulse(getval("pwX90"), phX90, 0.0, 0.0); obsunblank(); xmtrphase(v3); delay(wdumbo.r2); // Apply WPMLG Cycles During Acqusition decblank(); _blank34(); _wdumbo(wdumbo,phXwdumbo); endacq(); obsunblank(); decunblank(); _unblank34(); }
pulsesequence() { //Define Variables and Objects and Get Parameter Values double tHX3 = (getval("tHX"))/3.0; //Define MOIST CP in the Sequence MPSEQ sd = getsammyd("smydH",0,0.0,0.0,0,1); strncpy(sd.ch,"dec",3); putCmd("chHsmyd='dec'\n"); MPSEQ so = getsammyo("smyoX",0,0.0,0.0,0,1); strncpy(so.ch,"obs",3); putCmd("chXsmyo='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); d2 = sd.nelem*sd.telem; // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwH90") + getval("pwHlock")+ getval("tHX") + d2_; d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(phH90,4,table1); settable(phHlock,4,table2); settable(phHcomp,4,table3); settable(ph1Xhx,4,table4); settable(ph2Xhx,4,table5); settable(ph1Hhx,4,table6); settable(ph2Hhx,4,table7); settable(phHsmyd,4,table8); settable(phXsmyo,4,table9); settable(phHdec,4,table10); settable(phRec,4,table11); setreceiver(phRec); // Begin Sequence txphase(ph1Xhx); decphase(phH90); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H 90-degree Pulse decrgpulse(getval("pwH90"),phH90,0.0,0.0); // Prelock with Compensation Pulse decunblank(); decon(); if (getval("onHlock") > 0) { decphase(phHlock); delay(getval("pwHlock")); decphase(phHcomp); decpwrf(getval("aHcomp")); delay(getval("pwHcomp")); } // H to X MOIST Cross Polarization xmtron(); decphase(ph1Hhx); decpwrf(getval("aHhx")); delay(tHX3); txphase(ph1Xhx); decphase(ph1Hhx); delay(tHX3); txphase(ph2Xhx); decphase(ph2Hhx); delay(tHX3); xmtroff(); decoff(); // SAMMY Spinlocks on X and H _mpseqon(sd,phHsmyd); _mpseqon(so,phXsmyo); delay(d2); _mpseqoff(sd); _mpseqoff(so); decphase(phHdec); // Begin Acquisition obsblank(); _blank34(); _dseqon(dec); _decdoffset(getval("rd"),getval("ofHdec")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); decoffset(dof); obsunblank(); decunblank(); _unblank34(); }
pulsesequence() { // Define Variables and Objects and Get Parameter Values double pw1Xstmas = getval("pw1Xstmas"); double pw2Xstmas = getval("pw2Xstmas"); double tXzfselinit = getval("tXzfsel"); double tXzfsel = tXzfselinit - 3.0e-6; if (tXzfsel < 0.0) tXzfsel = 0.0; double d2init = getval("d2"); double d2 = d2init - pw1Xstmas/2.0 - pw2Xstmas/2.0; if (d2 < 0.0) d2 = 0.0; DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pw1Xstmas") + getval("pw2Xstmas") + getval("pwXzfsel"); d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = d2_ + tXzfsel + getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = d2_ + tXzfsel + getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(ph1Xstmas,4,table1); settable(ph2Xstmas,4,table2); settable(phXzfsel,8,table3); settable(phRec,8,table4); if (phase1 == 2) { tsadd(ph1Xstmas,1,4); } setreceiver(phRec); // Begin Sequence txphase(ph1Xstmas); decphase(zero); obspower(getval("tpwr")); obspwrf(getval("aXstmas")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H Decoupler on Before STMAS _dseqon(dec); // Two-Pulse STMAS rgpulse(getval("pw1Xstmas"),ph1Xstmas,0.0,0.0); txphase(ph2Xstmas); delay(d2); rgpulse(getval("pw2Xstmas"),ph2Xstmas,0.0,0.0); // Z-filter Pulse txphase(phXzfsel); obsblank(); obspower(getval("dbXzfsel")); obspwrf(getval("aXzfsel")); delay(3.0e-6); obsunblank(); delay(tXzfsel); rgpulse(getval("pwXzfsel"),phXzfsel,0.0,0.0); // Begin Acquisition obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
void pulsesequence() { // Define Variables and Objects and Get Parameter Values double tHXhsqcinit = getval("tHXhsqc"); //parameters for hsqcHX are implemented double pw1Hhxhsqc = getval("pw1Hhxhsqc"); //directly in the pulse sequence double pw2Hhxhsqc = getval("pw2Hhxhsqc"); double pmHhxhsqc = getval("pmHhxhsqc"); double pw1Xhxhsqc = getval("pw1Xhxhsqc"); double pw2Xhxhsqc = getval("pw2Xhxhsqc"); double aXhxhsqc = getval("aXhxhsqc"); double aHhxhsqc = getval("aHhxhsqc"); double d2init = getval("d2"); d2init = d2init - pw2Xhxhsqc; if (d2init < 0.0) d2init = 0.0; double d21 = d2init/2.0; double d22 = d2init/2.0; double tau1 = tHXhsqcinit; double tau2 = tHXhsqcinit; double tau3 = tHXhsqcinit; double tau4 = tHXhsqcinit; // Adjust First Composite 90 Simpulse double del1 = 0.0; int rev1 = 0; if ((pw1Xhxhsqc - pw1Hhxhsqc - 2.0*pmHhxhsqc)/2.0 > 0.0) { del1 = (pw1Xhxhsqc - pw1Hhxhsqc - 2.0*pmHhxhsqc)/2.0; rev1 = 0; } else if ((pw1Xhxhsqc - pw1Hhxhsqc) > 0.0) { del1 = (pw1Xhxhsqc - pw1Hhxhsqc)/2.0; rev1 = 1; } else { del1 = (pw1Hhxhsqc - pw1Xhxhsqc)/2.0; rev1 = 2; } del1 = (double) ((int) (del1/0.0125e-6 + 0.5)); del1 = del1*0.0125e-6; if (del1 < 0.05e-6) del1 = 0.0; if (rev1 == 0) { tau2 = tau2 - del1; if (tau2 < 0.0) tau2= 0.0; if (tau2 == 0.0) del1 = 0.0; d21 = d21 - del1; if (d21 < 0.0) d21 = 0.0; if (d21 == 0.0) del1 = 0.0; } // Adjust Composite 180 Simpulse double del2 = 0.0; int rev2 = 0; if ((pw2Xhxhsqc - pw2Hhxhsqc)/2.0 > 0.0) { del2 = (pw2Xhxhsqc - pw2Hhxhsqc )/2.0; rev2 = 0; } else { del2 = (pw2Hhxhsqc - pw2Xhxhsqc)/2.0; rev2 = 1; } del2 = (double) ((int) (del2/0.0125e-6 + 0.5)); del2 = del2*0.0125e-6; if (del2 < 0.05e-6) del2 = 0.0; if (rev2 == 0) { tau1 = tau1 - del2; tau2 = tau2 - del2; tau3 = tau3 - del2; tau4 = tau4 - del2; if (tau1 < 0.0) tau1 = 0.0; if (tau2 < 0.0) tau2 = 0.0; if (tau3 < 0.0) tau3 = 0.0; if (tau4 < 0.0) tau4 = 0.0; if (tau1 == 0.0) del2 = 0.0; if (tau2 == 0.0) del2 = 0.0; if (tau3 == 0.0) del2 = 0.0; if (tau4 == 0.0) del2 = 0.0; } // Adjust Second 90 Simpulse double del3 = 0.0; int rev3 = 0; if ((pw1Xhxhsqc - pw1Hhxhsqc)/2.0 > 0.0) { del3 = (pw1Xhxhsqc - pw1Hhxhsqc )/2.0; rev3 = 0; } else { del3 = (pw1Hhxhsqc - pw1Xhxhsqc)/2.0; rev3 = 1; } del3 = (double) ((int) (del3/0.0125e-6 + 0.5)); del3 = del3*0.0125e-6; if (del3 < 0.05e-6) del3 = 0.0; if (rev3 == 0) { tau3 = tau3 - del3; if (tau3 < 0.0) tau3 = 0.0; if (tau3 == 0.0) del3 = 0.0; d22 = d22 - del3; if (d22 < 0.0) d22 = 0.0; if (d22 == 0.0) del3 = 0.0; } MPSEQ fh = getfslg("fslgH",0,0.0,0.0,0,1); strncpy(fh.ch,"dec",3); putCmd("chHfslg='dec'\n"); CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwH90") + getval("tHX") + 4.0*tHXhsqcinit + d2_ + 4.0*pmHhxhsqc + pw1Hhxhsqc + pw2Hhxhsqc; d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(phH90,4,table1); settable(phXhx,4,table2); settable(phHhx,4,table3); settable(ph1Hhxhsqc,4,table4); settable(ph2Hhxhsqc,4,table5); settable(ph1Xhxhsqc,4,table6); settable(ph3Hhxhsqc,4,table7); settable(ph4Hhxhsqc,4,table8); settable(ph2Xhxhsqc,8,table9); settable(ph5Hhxhsqc,4,table10); settable(ph3Xhxhsqc,16,table11); settable(ph6Hhxhsqc,4,table12); settable(ph4Xhxhsqc,4,table13); settable(ph7Hhxhsqc,4,table14); settable(ph5Xhxhsqc,4,table15); settable(phRec,8,table16); // Add STATES TPPI (States with FAD) tsadd(ph6Hhxhsqc,2*d2_index,4); tsadd(phRec,2*d2_index,4); if (phase1 == 2) { tsadd(ph6Hhxhsqc,3,4); } setreceiver(phRec); // Begin Sequence txphase(phXhx); decphase(phH90); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H to X Cross Polarization decrgpulse(getval("pwH90"),phH90,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); // Begin hsqcHX with fh (FSLG) Between Pulses _mpseqon(fh,ph1Hhxhsqc); // First "tau/2.0" Delay obspwrf(aXhxhsqc); txphase(ph1Xhxhsqc); delay(tau1); // First Simultaneous HX 180 Pulse if (rev2 == 0) { xmtron(); if (del2 > 0.0) delay(del2); _mpseqoff(fh); decphase(ph2Hhxhsqc); decpwrf(aHhxhsqc); decon(); delay(pw2Hhxhsqc); decoff(); _mpseqon(fh,ph1Hhxhsqc); if (del2 > 0.0) delay(del2); xmtroff(); } else { _mpseqoff(fh); decphase(ph2Hhxhsqc); decpwrf(aHhxhsqc); decon(); if (del2 > 0.0) delay(del2); xmtron(); delay(pw2Xhxhsqc); xmtroff(); if (del2 > 0.0) delay(del2); decoff(); _mpseqon(fh,ph1Hhxhsqc); } // Second "tau/2" Delay txphase(ph2Xhxhsqc); delay(tau2); // Simultaneous HX (Tilted 90) Composite Pulse if (rev1 == 0) { xmtron(); if (del1 > 0.0) delay(del1); _mpseqoff(fh); decphase(ph3Hhxhsqc); decpwrf(aHhxhsqc); decon(); delay(pmHhxhsqc); decphase(ph4Hhxhsqc); delay(pw1Hhxhsqc); decphase(ph5Hhxhsqc); delay(pmHhxhsqc); decoff(); _mpseqon(fh,ph1Hhxhsqc); if (del1 > 0.0) delay(del1); xmtroff(); } else if (rev1 == 1) { _mpseqoff(fh); decphase(ph3Hhxhsqc); decpwrf(aHhxhsqc); decon(); delay(pmHhxhsqc - del1); xmtron(); if (del1 > 0.0) delay(del1); decphase(ph4Hhxhsqc); delay(pw1Hhxhsqc); decphase(ph5Hhxhsqc); if (del1 > 0.0) delay(del1); xmtroff(); delay(pmHhxhsqc - del1); decoff(); _mpseqon(fh,ph1Hhxhsqc); } else { _mpseqoff(fh); decphase(ph3Hhxhsqc); decpwrf(aHhxhsqc); decon(); delay(pmHhxhsqc); decphase(ph4Hhxhsqc); if (del1 > 0.0) delay(del1); xmtron(); delay(pw1Xhxhsqc); xmtroff(); if (del1 > 0.0) delay(del1); decphase(ph5Hhxhsqc); delay(pmHhxhsqc); decoff(); _mpseqon(fh,ph1Hhxhsqc); } // F1 Delay with X Refocussing Pulse txphase(ph3Xhxhsqc); delay(d21); double flag = getval("flag"); if (flag == 0) { rgpulse(pw2Xhxhsqc, ph3Xhxhsqc, 0.0,0.0); } else { delay(pw2Xhxhsqc); } obsunblank(); txphase(ph4Xhxhsqc); delay(d22); // Second Simulaneous HX Pulse (90 Only) if (rev3 == 0) { xmtron(); if (del3 > 0.0) delay(del3); _mpseqoff(fh); decphase(ph6Hhxhsqc); decpwrf(aHhxhsqc); decon(); delay(pw1Hhxhsqc); decoff(); _mpseqon(fh,ph1Hhxhsqc); if (del3 > 0.0) delay(del3); xmtroff(); } else { _mpseqoff(fh); decphase(ph6Hhxhsqc); decpwrf(aHhxhsqc); decon(); if (del3 > 0.0) delay(del3); xmtron(); delay(pw1Xhxhsqc); xmtroff(); if (del3 > 0.0) delay(del3); decoff(); _mpseqon(fh,ph1Hhxhsqc); } // Third "tau/2.0" Delay txphase(ph5Xhxhsqc); delay(tau3); // Second Simultaneous HX 180 Pulse if (rev2 == 0) { xmtron(); if (del2 > 0.0) delay(del2); _mpseqoff(fh); decphase(ph7Hhxhsqc); decpwrf(aHhxhsqc); decon(); delay(pw2Hhxhsqc); decoff(); _mpseqon(fh,ph1Hhxhsqc); if (del2 > 0.0) delay(del2); xmtroff(); } else { _mpseqoff(fh); decphase(ph7Hhxhsqc); decpwrf(aHhxhsqc); decon(); if (del2 > 0.0) delay(del2); xmtron(); delay(pw2Xhxhsqc); xmtroff(); if (del2 > 0.0) delay(del2); decoff(); _mpseqon(fh,ph1Hhxhsqc); } // Fourth "tau/2.0" Delay delay(tau4); _mpseqoff(fh); // Begin Acquisition decphase(phHhx); _dseqon(dec); obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
int init_sdr_hdr (SDR_HDR *sh, /* ptr to space for sdr data hdr. */ DATA_HDR *hdr, /* initial DATA_HDR for sdr record. */ BS *extra_bs) /* ptr to block-specific blockettes. */ { int status = 0; int blockette_space; /* # of bytes required for blockettes. */ int n_extra_bs; /* # of extra blockettes. */ BS *bs; /* ptr to blockette structure. */ BS *last_bs; /* ptr to last permanent blockette. */ int align; /* alignment in bytes required for data.*/ int swapflag; /* flag to indicate byteswapping. */ MS_ATTR attr; int blksize = hdr->blksize; if (my_wordorder < 0) get_my_wordorder(); swapflag = (my_wordorder != hdr->hdr_wordorder); /* Determine the space required for all of the blockettes. */ for (bs=hdr->pblockettes, blockette_space=0, last_bs=NULL; bs!=NULL; last_bs=bs, bs=bs->next) { blockette_space += bs->len + ((bs->len%4) ? 4-(bs->len%4) : 0); } for (bs=extra_bs, n_extra_bs=0; bs!=NULL; bs=bs->next, n_extra_bs++) { blockette_space += bs->len + ((bs->len%4) ? 4-(bs->len%4) : 0); } /* Temporarily add the list of extra blockettes to the list of */ /* permanent blockettes. */ if (extra_bs) { if (last_bs) last_bs->next = extra_bs; else hdr->pblockettes = extra_bs; hdr->num_blockettes += n_extra_bs; } /* Ensure that first_data points to appropriate offset for data. */ /* Some data formats (eg the STEIM compressed formats) require */ /* first_data to be on a frame boundary. */ attr = get_ms_attr(hdr); if (attr.alignment == 0) return (MS_ERROR); align = attr.alignment; hdr->first_data = ((sizeof(SDR_HDR)+blockette_space+align-1)/align)*align; /* Update any blockettes that have block-specific info. */ if ((bs=find_blockette(hdr, 1000))) { /* Ensure we have proper data in the blockette. */ BLOCKETTE_1000 *b1000 = (BLOCKETTE_1000 *) bs->pb; /* These are all byte values, so I can ignore wordorder. */ b1000->data_rec_len = roundoff(log2((double)blksize)); b1000->format = hdr->data_type; b1000->word_order = hdr->data_wordorder; } if ((bs=find_blockette(hdr, 1001))) { /* Ensure we have proper data in the blockette. */ /* Mark all frames as being in use. */ BLOCKETTE_1001 *b1001 = (BLOCKETTE_1001 *) bs->pb; /* These are all byte values, so I can ignore wordorder. */ b1001->frame_count = hdr->num_data_frames; b1001->usec99 = hdr->hdrtime.usec % 100; } /* Create the SDR fixed data header and data blockettes. */ /* Parts of the header that do not change from block to block. */ sh->space_1 = ' '; capnstr(sh->station_id,hdr->station_id,5); capnstr(sh->channel_id,hdr->channel_id,3); capnstr(sh->network_id,hdr->network_id,2); capnstr(sh->location_id,hdr->location_id,2); sh->sample_rate_factor = hdr->sample_rate; sh->sample_rate_mult = (hdr->sample_rate) ? hdr->sample_rate_mult : 0; /* Parts of the header that change with each block. */ sh->data_hdr_ind = hdr->record_type; capnint(sh->seq_no,hdr->seq_no,6); sh->time = encode_time_sdr(hdr->hdrtime, hdr->hdr_wordorder); sh->activity_flags = hdr->activity_flags; sh->io_flags = hdr->io_flags; sh->data_quality_flags = hdr->data_quality_flags; sh->num_samples = 0; sh->num_ticks_correction = hdr->num_ticks_correction; /* Parts of the header that depend on the blockettes. */ sh->first_data = hdr->first_data; sh->num_blockettes = hdr->num_blockettes; sh->first_blockette = hdr->first_blockette; /* Output any data blockettes. */ if (hdr->num_blockettes > 0) { write_blockettes(hdr, (char *)sh); } /* Unlink the extra blockettes from the data_hdr. */ if (extra_bs) { if (last_bs) last_bs->next = NULL; else hdr->pblockettes = NULL; hdr->num_blockettes -= n_extra_bs; } if (swapflag) { swab2 ((short int *)&sh->num_samples); swab2 ((short int *)&sh->sample_rate_factor); swab2 ((short int *)&sh->sample_rate_mult); swab2 ((short int *)&sh->first_data); swab2 ((short int *)&sh->first_blockette); swab4 ((int *)&sh->num_ticks_correction); } /* Zero any space between the end of the blockettes and first_data. */ memset ((char*)sh + (sizeof(SDR_HDR)+blockette_space), 0, hdr->first_data - (sizeof(SDR_HDR)+blockette_space)); /* Return status our SDR header creation. */ return (status); }
pulsesequence() { // ========================================================= // Define Variables and Objects and Get Parameter Values // ========================================================= // -------------------------------- // Acquisition Decoupling // ------------------------------- char Hseq[MAXSTR]; getstr("Hseq",Hseq); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // --------------------------------------------- // Determine taur, One Rotor Cycle and Set tHrr. // --------------------------------------------- double srate = getval("srate"); double taur = 0.0; if (srate >= 500.0) taur = roundoff((1.0/srate), 0.125e-6); else { abort_message("ABORT: Spin Rate (srate) must be greater than 500\n"); } double tHrr = getval("nHrr")*taur; double tHrrret= 2.0*tHrr; putCmd("tHrrret = %f\n",tHrrret*1.0e6); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); //------------------------------ // Dutycycle Protection //------------------------------ DUTY d = init_dutycycle(); d.dutyon = getval("pwX90"); d.dutyoff = d1 + 4.0e-6; if (getval("aHrr") > 0.0) d.dutyon += 2.0*tHrr; d.c1 = d.c1 + (!strcmp(Hseq,"tppm")); d.c1 = d.c1 + ((!strcmp(Hseq,"tppm")) && (dec.t.a > 0.0)); d.t1 = getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(Hseq,"spinal")); d.c2 = d.c2 + ((!strcmp(Hseq,"spinal")) && (dec.s.a > 0.0)); d.t2 = getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); //--------------------------- // Set Phase Tables //--------------------------- settable(phX90,4,tblX90); settable(phHrr,4,tblHrr); settable(ph1Hrr,4,tblHrr2); settable(phRec,4,tblRec); setreceiver(phRec); //=========================== // Begin Sequence //=========================== txphase(phX90); decphase(zero); obspwrf(getval("aX90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); //---------------------------- // X Direct Polarization //---------------------------- rgpulse(getval("pwX90"),phX90,0.0,0.0); obsunblank(); // ----------------------------- // Begin Rotary Resonance // ----------------------------- if(getval("aHrr") > 0.0) { obspwrf(getval("aHrr")); txphase(phHrr); xmtron(); delay(tHrr); txphase(ph1Hrr); delay(tHrr); xmtroff(); } //=========================== // Begin Acquisition //=========================== _dseqon(dec); obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
double *synt_noise(double **d, int32_t Xsize, int32_t bands, int32_t *samplecount, int32_t samplerate, double basefreq, double pixpersec, double bpo) { int32_t i; // general purpose iterator int32_t ib; // bands iterator int32_t il; // loop iterator double *s; // final signal double coef; double *noise; // filtered looped noise double loop_size_sec=LOOP_SIZE_SEC; // size of the filter bank loop, in seconds. Later to be taken from user input int32_t loop_size; // size of the filter bank loop, in samples. Deduced from loop_size_sec int32_t loop_size_min; // minimum required size for the filter bank loop, in samples. Calculated from the longest windowed sinc's length double *pink_noise; // original pink noise (in the frequency domain) double mag, phase; // parameters for the creation of pink_noise's samples double *envelope; // interpolated envelope double *lut; // Blackman Sqaure look-up table double *freq; // frequency look-up table double maxfreq; // central frequency of the last band int32_t Fa; // Fa is the index of the band's start in the frequency domain int32_t Fd; // Fd is the index of the band's end in the frequency domain double La; // La is the log2 of the frequency of Fa double Ld; // Ld is the log2 of the frequency of Fd double Li; // Li is the iterative frequency between La and Ld defined logarithmically freq = freqarray(basefreq, bands, bpo); if (LOGBASE==1.0) maxfreq = bpo; // in linear mode we use bpo to store the maxfreq since we couldn't deduce maxfreq otherwise else maxfreq = basefreq * pow(LOGBASE, ((double) (bands-1)/ bpo)); clocka=gettime(); *samplecount = roundoff(Xsize/pixpersec); // calculation of the length of the final signal printf("Sound duration : %.3f s\n", (double) *samplecount/samplerate); s = calloc (*samplecount, sizeof(double)); // allocation of the final signal envelope = calloc (*samplecount, sizeof(double)); // allocation of the interpolated envelope //********Loop size calculation******** loop_size = loop_size_sec * samplerate; if (LOGBASE==1.0) loop_size_min = (int32_t) roundoff(4.0*5.0/ freq[1]-freq[0]); // linear mode else loop_size_min = (int32_t) roundoff(2.0*5.0/((freq[0] * pow(2.0, -1.0/(bpo))) * (1.0 - pow(2.0, -1.0 / bpo)))); // this is the estimate of how many samples the longest FIR will take up in the time domain if (loop_size_min > loop_size) loop_size = loop_size_min; loop_size = nextsprime(loop_size); // enlarge the loop_size to the next multiple of short primes in order to make IFFTs faster //--------Loop size calculation-------- //********Pink noise generation******** pink_noise = calloc (loop_size, sizeof(double)); for (i=1; i<(loop_size+1)>>1; i++) { mag = pow((double) i, 0.5 - 0.5*LOGBASE); // FIXME something's not necessarily right with that formula phase = dblrand() * pi; // random phase between -pi and +pi pink_noise[i]= mag * cos(phase); // real part pink_noise[loop_size-i]= mag * sin(phase); // imaginary part } //--------Pink noise generation-------- noise = malloc(loop_size * sizeof(double)); // allocate noise lut = bmsq_lut(BMSQ_LUT_SIZE); // Blackman Square look-up table initalisation for (ib=0; ib<bands; ib++) { printf("%4d/%d\r", ib+1, bands); memset(noise, 0, loop_size * sizeof(double)); // reset filtered noise //********Filtering******** Fa = roundoff(log_pos((double) (ib-1)/(double) (bands-1), basefreq, maxfreq) * loop_size); Fd = roundoff(log_pos((double) (ib+1)/(double) (bands-1), basefreq, maxfreq) * loop_size); La = log_pos_inv((double) Fa / (double) loop_size, basefreq, maxfreq); Ld = log_pos_inv((double) Fd / (double) loop_size, basefreq, maxfreq); if (Fd > loop_size/2) Fd = loop_size/2; // stop reading if reaching the Nyquist frequency if (Fa<1) Fa=1; printf("%4d/%d %.2f Hz - %.2f Hz\r", ib+1, bands, (double) Fa*samplerate/loop_size, (double) Fd*samplerate/loop_size); for (i=Fa; i<Fd; i++) { Li = log_pos_inv((double) i / (double) loop_size, basefreq, maxfreq); // calculation of the logarithmic position Li = (Li-La)/(Ld-La); coef = 0.5 - 0.5*cos(2.0*pi*Li); // Hann function noise[i+1] = pink_noise[i+1] * coef; noise[loop_size-1-i] = pink_noise[loop_size-1-i] * coef; } //--------Filtering-------- fft(noise, noise, loop_size, 1); // IFFT of the filtered noise memset(envelope, 0, *samplecount * sizeof(double)); // blank the envelope blackman_square_interpolation(d[bands-ib-1], envelope, Xsize, *samplecount, lut, BMSQ_LUT_SIZE); // interpolation of the envelope il = 0; for (i=0; i<*samplecount; i++) { s[i] += envelope[i] * noise[il]; // modulation il++; // increment loop iterator if (il==loop_size) // if the array iterator has reached the end of the array, it's reset il=0; } } printf("\n"); normi(&s, *samplecount, 1, 1.0); return s; }
double *synt_sine(double **d, int32_t Xsize, int32_t bands, int32_t *samplecount, int32_t samplerate, double basefreq, double pixpersec, double bpo) { double *s, *freq, *filter, *sband, sine[4], rphase; int32_t i, ib; int32_t Fc, Bc, Mh, Mn, sbsize; /* d is the original image (spectrogram) s is the output sound sband is the band's envelope upsampled and shifted up in frequency sbsize is the length of sband sine is the random sine look-up table *samplecount is the output sound's length ib is the band iterator i is a general purpose iterator bands is the total count of bands Fc is the index of the band's centre in the frequency domain on the new signal Bc is the index of the band's centre in the frequency domain on sband (its imaginary match being sbsize-Bc) Mh is the length of the real or imaginary part of the envelope's FFT, DC element included and Nyquist element excluded Mn is the length of the real or imaginary part of the sound's FFT, DC element included and Nyquist element excluded freq is the band's central frequency rphase is the band's sine's random phase */ freq = freqarray(basefreq, bands, bpo); clocka=gettime(); sbsize = nextsprime(Xsize * 2); // In Circular mode keep it to sbsize = Xsize * 2; *samplecount = roundoff(Xsize/pixpersec); printf("Sound duration : %.3f s\n", (double) *samplecount/samplerate); *samplecount = roundoff(0.5*sbsize/pixpersec); // Do not change this value as it would stretch envelopes s = calloc(*samplecount, sizeof(double)); // allocation of the sound signal sband = malloc (sbsize * sizeof(double)); // allocation of the shifted band Bc = roundoff(0.25 * (double) sbsize); Mh = (sbsize + 1) >> 1; Mn = (*samplecount + 1) >> 1; filter = wsinc_max(Mh, 1.0/TRANSITION_BW_SYNT); // generation of the frequency-domain filter for (ib=0; ib<bands; ib++) { memset(sband, 0, sbsize * sizeof(double)); // reset sband //********Frequency shifting******** rphase = dblrand() * pi; // random phase between -pi and +pi for (i=0; i<4; i++) // generating the random sine LUT sine[i]=cos(i*2.0*pi*0.25 + rphase); for (i=0; i<Xsize; i++) // envelope sampling rate * 2 and frequency shifting by 0.25 { if ((i & 1) == 0) { sband[i<<1] = d[bands-ib-1][i] * sine[0]; sband[(i<<1) + 1] = d[bands-ib-1][i] * sine[1]; } else { sband[i<<1] = d[bands-ib-1][i] * sine[2]; sband[(i<<1) + 1] = d[bands-ib-1][i] * sine[3]; } } //--------Frequency shifting-------- fft(sband, sband, sbsize, 0); // FFT of the envelope Fc = roundoff(freq[ib] * *samplecount); // band's centre index (envelope's DC element) printf("%4d/%d %.2f Hz\r", ib+1, bands, (double) Fc*samplerate / *samplecount); //********Write FFT******** for (i=1; i<Mh; i++) { if (Fc-Bc+i > 0 && Fc-Bc+i < Mn) // if we're between frequencies 0 and 0.5 of the new signal and that we're not at Fc { s[i+Fc-Bc] += sband[i] * filter[i]; // Real part s[*samplecount-(i+Fc-Bc)] += sband[sbsize-i] * filter[i]; // Imaginary part } } //--------Write FFT-------- } printf("\n"); fft(s, s, *samplecount, 1); // IFFT of the final sound *samplecount = roundoff(Xsize/pixpersec); // chopping tails by ignoring them normi(&s, *samplecount, 1, 1.0); return s; }
pulsesequence() { // Define Variables and Objects and Get Parameter Values CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); MPSEQ fh = getfslg("fslgH",0,0.0,0.0,0,1); strncpy(fh.ch,"dec",3); putCmd("chHfslg='dec'\n"); MPSEQ fx = getfslg("fslgX",0,0.0,0.0,0,1); strncpy(fx.ch,"obs",3); putCmd("chXfslg='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwH90") + getval("tHX") + d2_; d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(phH90,4,table1); settable(phXhx,4,table2); settable(phHhx,4,table3); settable(phHtilt,4,table4); settable(phHfslg,4,table5); settable(phXlock,4,table6); settable(phRec,4,table7); setreceiver(phRec); // Begin Sequence txphase(phXhx); decphase(phH90); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H to X Cross Polarization decrgpulse(getval("pwH90"),phH90,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); // Tilt Pulse on H with Continued X Spinlock xmtron(); decon(); decpwrf(getval("aH90")); obspwrf(getval("aXhx")); decrgpulse(getval("pwHtilt"),phHtilt,0.0,0.0); // FSLG Spinlocks on X and H xmtron(); decon(); _mpseqon(fh,phHfslg); _mpseqon(fx,phXlock); delay(d2); _mpseqoff(fh); _mpseqoff(fx); // Begin Acquisition obsblank(); _blank34(); _dseqon(dec); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
pulsesequence() { // Define Variables and Objects and Get Parameter Values SHAPE p1 = getpulse("90H",0.0,0.0,1,0); strncpy(p1.pars.ch,"dec",3); putCmd("chH90='dec'\n"); p1.pars.array = disarry("xx", p1.pars.array); p1 = update_shape(p1,0.0,0.0,1); MPSEQ ph = getpmlgxmx("pmlgH",0,0.0,0.0,1,0); strncpy(ph.ch,"dec",3); putCmd("chHpmlg='dec'\n"); double pwHpmlg = getval("pwHpmlg"); ph.nelem = (int) (d2/(2.0*pwHpmlg) + 0.1); ph.array = disarry("xx", ph.array); ph = update_mpseq(ph,0,p1.pars.phAccum,p1.pars.phInt,1); SHAPE p2 = getpulse("90H",0.0,0.0,2,0); strncpy(p2.pars.ch,"dec",3); putCmd("chH90='dec'\n"); p2.pars.array = disarry("xx", p2.pars.array); p2 = update_shape(p2,ph.phAccum,ph.phInt,2); double pwX180 = getval("pwX180"); double d22 = ph.t/2.0 - pwX180/2.0; if (d22 < 0.0) d22 = 0.0; // CP hx and DSEQ dec Return to the Reference Phase CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = p1.pars.t + d2_ + p2.pars.t + getval("pwH90") + getval("pwHtilt") + getval("tHX"); d.dutyoff = d1 + 4.0e-6 + getval("tHmix"); d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(ph1H90,4,table1); settable(phHpmlg,4,table2); settable(ph2H90,4,table3); settable(ph3H90,4,table4); settable(phHtilt,4,table5); settable(phXhx,4,table6); settable(phHhx,4,table7); settable(phRec,4,table8); //Add STATES TPPI ("States with "FAD") tsadd(phRec,2*d2_index,4); if (phase1 == 2) { tsadd(ph2H90,2*d2_index+3,4); } else { tsadd(ph2H90,2*d2_index,4); } setreceiver(phRec); // Begin Sequence txphase(phXhx); decphase(ph1H90); obspwrf(getval("aX180")); decpwrf(getval("aH90")); obsunblank();decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // Offset H Preparation with a Tilt Pulse _shape(p1,ph1H90); // Offset SAMn Spinlock on H During F1 with Optional pwX180 _mpseqon(ph,phHpmlg); delay(d22); rgpulse(pwX180,zero,0.0,0.0); obspwrf(getval("aX90")); txphase(phXhx); delay(d22); _mpseqoff(ph); // Offset 90-degree Pulse to Zed and Spin-Diffusion Mix _shape(p2,ph2H90); decpwrf(getval("aH90")); delay(getval("tHmix")); // H90, 35-degree Tilt and H-to-X Cross Polarization with LG Offset decrgpulse(getval("pwH90"),ph3H90,0.0,0.0); decunblank(); decrgpulse(getval("pwHtilt"),phHtilt,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); // Begin Acquisition obsblank(); _blank34(); _dseqon(dec); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
pulsesequence() { // Define Variables and Objects and Get Parameter Values double pwX90 = getval("pwX90"); double d22 = d2/2.0 - pwX90; if (d22 < 0.0) d22 = 0.0; MPSEQ fh = getfslg("fslgH",0,0.0,0.0,0,1); strncpy(fh.ch,"dec",3); putCmd("chHfslg='dec'\n"); CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = 3.0*getval("pwHtilt") + d2_ + getval("pwH90") + getval("tHX"); d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables settable(phHtilt,4,table1); settable(phHfslg,4,table2); settable(phHtilt2,4,table3); settable(phH90,4,table4); settable(phHtilt3,4,table5); settable(phXhx,4,table6); settable(phHhx,4,table7); settable(phRec,4,table8); //Add STATES TPPI ("States with "FAD") tsadd(phRec,2*d2_index,4); if (phase1 == 2) { tsadd(phHtilt3,2*d2_index+3,4); tsadd(phHhx,2*d2_index+3,4); } else { tsadd(phHtilt3,2*d2_index,4); tsadd(phHhx,2*d2_index,4); } setreceiver(phRec); // Begin Sequence txphase(phXhx); decphase(phHtilt); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank();decunblank();_unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H Preparation with a Tilt Pulse decrgpulse(getval("pwHtilt"),phHtilt,0.0,0.0); // FSLG spinlock on H and Reverse Tilt to Zed _mpseqon(fh,phHfslg); delay(d22); rgpulse(2.0*pwX90,zero,0.0,0.0); txphase(phXhx); delay(d22); _mpseqoff(fh); decpwrf(getval("aH90")); decrgpulse(getval("pwHtilt"),phHtilt2,0.0,0.0); // H 90 and Ramped H to X Cross Polarization with LG Offset decrgpulse(getval("pwH90"),phH90,0.0,0.0); decrgpulse(getval("pwHtilt"),phHtilt3,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); // Begin Acquisition obsblank(); _blank34(); _dseqon(dec); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
void pulsesequence() { // Define Variables and Objects and Get Parameter Values CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); MPSEQ spc5 = getspc5("spc5X",0,0.0,0.0,0,1); MPSEQ spc5ref = getspc5("spc5X",spc5.iSuper,spc5.phAccum,spc5.phInt,1,1); strncpy(spc5.ch,"obs",3); putCmd("chXspc5='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwH90") + getval("tHX") + getval("pwX90") + spc5.t + spc5ref.t; d.dutyoff = d1 + 4.0e-6 + 2.0*getval("tZF"); d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = d2_ + getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = d2_ + getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Create Phasetables settable(phH90,4,table1); settable(phHhx,4,table2); settable(phXhx,4,table3); settable(phXmix1,4,table4); settable(phXmix2,4,table5); settable(phRec,4,table6); setreceiver(phRec); if (phase1 == 2) tsadd(phXhx,1,4); // Begin Sequence txphase(phXhx); decphase(phH90); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H to X Cross Polarization decrgpulse(getval("pwH90"),phH90,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); // F2 Indirect Period for X obspwrf(getval("aX90")); _dseqon(dec); delay(d2); _dseqoff(dec); // Mixing with SPC5 Recoupling rgpulse(getval("pwX90"),phXmix1,0.0,0.0); obspwrf(getval("aXspc5")); xmtrphase(v1); txphase(phXmix1); delay(getval("tZF")); decpwrf(getval("aHmix")); decon(); _mpseq(spc5, phXmix1); xmtrphase(v2); txphase(phXmix2); _mpseq(spc5ref, phXmix2); decoff(); obspwrf(getval("aX90")); xmtrphase(zero); txphase(phXmix2); delay(getval("tZF")); rgpulse(getval("pwX90"),phXmix2,0.0,0.0); // Begin Acquisition _dseqon(dec); obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
pulsesequence() { // Define Variables and Objects and Get Parameter Values CP hy = getcp("HY",0.0,0.0,0,1); strncpy(hy.fr,"dec",3); strncpy(hy.to,"dec2",4); putCmd("frHY='dec'\n"); putCmd("toHY='dec2'\n"); CP yx = getcp("YX",0.0,0.0,0,1); strncpy(yx.fr,"dec2",4); strncpy(yx.to,"obs",3); putCmd("frYX='dec2'\n"); putCmd("toYX='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); // Set Constant-time Period for d3. if (d3_index == 0) d3_init = getval("d3"); double d3_ = (ni - 1)/sw1 + d3_init; putCmd("d3acqret = %f\n",roundoff(d3_,12.5e-9)); putCmd("d3dwret = %f\n",roundoff(1.0/sw2,12.5e-9)); // Set Mixing Period to N Rotor Cycles double taur,mix,srate; mix = getval("tXmix"); srate = getval("srate"); taur = 0.0; if (srate >= 500.0) taur = roundoff((1.0/srate), 0.125e-6); else { printf("ABORT: Spin Rate (srate) must be greater than 500\n"); psg_abort(1); } mix = roundoff(mix,taur); mix = mix - getval("pwX90"); if (mix < 0.0) mix = 0.0; //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwY90") + getval("pwH90") + getval("tHY") + getval("tYX") + 2.0*getval("pwX90") + mix; d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = d2 + d3 + getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = d2 + d3 + getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Create Phasetables settable(phH90,4,table1); settable(phHhy,4,table2); settable(phY90,4,table3); settable(phYhy,4,table4); settable(phHyx,4,table5); settable(phYyx,4,table6); settable(phXyx,8,table7); settable(phXmix1,8,table8); settable(phXmix2,8,table9); settable(phRec,8,table10); if (phase2 == 2) tsadd(phXyx,1,4); if (phase1 == 2) tsadd(phYhy,1,4); // Begin Sequence setreceiver(phRec); txphase(phXyx); decphase(phH90); dec2phase(phY90); obspwrf(getval("aXyx")); decpwrf(getval("aH90")); dec2pwrf(getval("aY90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H to Y Cross Polarization with a Y Prepulse dec2rgpulse(getval("pwY90"),phY90,0.0,0.0); dec2phase(phYhy); dec2pwrf(getval("aYyx")); decrgpulse(getval("pwH90"),phH90,0.0,0.0); decphase(phHhy); _cp_(hy,phHhy,phYhy); // F1 Indirect Period For Y _dseqon(dec); delay(d2); _dseqoff(dec); // Y to X Cross Polarization decphase(phHyx); dec2phase(phYyx); decpwrf(getval("aHyx")); decunblank(); decon(); _cp_(yx,phYyx,phXyx); decphase(phHhy); decoff(); // F2 Indirect Period for X txphase(phXmix1); obspwrf(getval("aX90")); _dseqon(dec); delay(d3); _dseqoff(dec); // RAD(DARR) Mixing For X decpwrf(getval("aHmix")); decunblank(); decon(); rgpulse(getval("pwX90"),phXmix1,0.0,0.0); txphase(phXmix2); obsunblank(); delay(mix); rgpulse(getval("pwX90"),phXmix2,0.0,0.0); decoff(); // Begin Acquisition _dseqon(dec); obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
pulsesequence() { // Define Variables and Objects and Get Parameter Values double aXfam2 = getval("aXfam2"); double pw1Xfam2 = getval("pw1Xfam2"); double pw2Xfam2 = getval("pw2Xfam2"); double pw3Xfam2 = getval("pw3Xfam2"); double pw4Xfam2 = getval("pw4Xfam2"); double nXfam2 = getval("nXfam2"); initval(nXfam2,v4); putCmd("pw2Xmqmas=pwXfam1"); // Sequence uses pwXfam1 and sets pw2Xmqmas double d2init = getval("d2"); // Define the Split d2 in the Pulse Sequence double ival = getval("ival"); double d20 = 1.0; double d21 = 0.0; double d22 = 0.0; if (ival == 1.5) { d20 = 9.0*d2init/16.0; d21 = 7.0*d2init/16.0; d22 = 0.0; } else if (ival == 2.5) { d20 = 12.0*d2init/31.0; d21 = 0.0*d2init/31.0; d22 = 19.0*d2init/31.0; } else { d20 = 1.0*d2init; d21 = 0.0*d2init; d22 = 0.0*d2init; } double tXechselinit = getval("tXechsel"); // Adjust the selective echo delay for the double tXechsel = tXechselinit - 3.0e-6; // attenuator switch time. if (tXechsel < 0.0) tXechsel = 0.0; DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pw1Xmqmas") + nXfam2*(pw1Xfam2 + pw2Xfam2 + pw3Xfam2 +pw4Xfam2) + getval("pwXechsel"); d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = d2_ + tXechselinit + getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = d2_ + tXechselinit + getval("rd") + getval("ad") + at; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Phase Tables if (phase1 == 0) { settable(phf1Xmqmas,12,table1); settable(ph1Xfam2,6,table2); settable(ph2Xfam2,6,table3); settable(phfXechsel,96,table4); settable(phRec,48,table5); } else { settable(phf1Xmqmas,6,table6); settable(ph1Xfam2,6,table7); settable(ph2Xfam2,6,table8); settable(phfXechsel,48,table9); settable(phRec,24,table10); if (phase1 == 2) { tsadd(phf1Xmqmas,30,360); } } setreceiver(phRec); obsstepsize(1.0); // Begin Sequence xmtrphase(phf1Xmqmas); decphase(zero); obspower(getval("tpwr")); obspwrf(getval("aXmqmas")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H Decoupler on Before MQMAS _dseqon(dec); // Two-Pulse MQMAS with DFS Conversion rgpulse(getval("pw1Xmqmas"),zero,0.0,0.0); xmtrphase(zero); txphase(ph1Xfam2); obspwrf(aXfam2); delay(d20); // X FAM2 Pulse loop(v4,v5); xmtron(); delay(pw1Xfam2); xmtroff(); txphase(ph2Xfam2); delay(pw2Xfam2); xmtron(); delay(pw3Xfam2); xmtroff(); txphase(ph2Xfam2); delay(pw4Xfam2); endloop(v5); // Tau Delay and Second Selective Echo Pulse xmtrphase(phfXechsel); obsblank(); obspower(getval("dbXechsel")); obspwrf(getval("aXechsel")); delay(3.0e-6); obsunblank(); delay(d21 + tXechsel); rgpulse(getval("pwXechsel"),zero,0.0,0.0); delay(d22); // Begin Acquisition obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
void Nodes_method::run(Program_options & options, ostream & output) { ofstream os; //for writing to *.plt files string pltfile; //name of plotfile being written string confile; //name of configuration of electrons to be being written double max_value,min_value; int count; Array1 <doublevar> xyz(3), xyz2(3), resolution_array(3); //position of electron "in" MO Array1 <int> D_array1(3); //dummy array1 Array2 <doublevar> oldpos(mywalker->electronSize(),3); Array1 <doublevar> tmp(3); D_array1=0; //sets all 3 components to 0. use as counter for gridpoints D_array1(0)=roundoff((minmax(1)-minmax(0))/resolution); D_array1(1)=roundoff((minmax(3)-minmax(2))/resolution); D_array1(2)=roundoff((minmax(5)-minmax(4))/resolution); resolution_array(0)=(minmax(1)-minmax(0))/(D_array1(0)-1); resolution_array(1)=(minmax(3)-minmax(2))/(D_array1(1)-1); resolution_array(2)=(minmax(5)-minmax(4))/(D_array1(2)-1); Array2 <doublevar> grid(plots.GetSize(),D_array1(0)*D_array1(1)*D_array1(2)); Wf_return wfvals(wf->nfunc(), 2); //where wfval fist index labels //wf number ie. ground state // excited state and so on, and second label is for two values, sign and log(wf). //scan electron positions cout << "Using these electron positions:"<<endl; for(int i=0; i<mywalker->electronSize(); i++){ mywalker->getElectronPos(i, tmp); cout.precision(5); cout.width(8); cout <<i+1<<" "<<tmp(0)<<" "<<tmp(1)<<" "<<tmp(2)<<endl; for (int d=0;d<3;d++) oldpos(i,d)=tmp(d); // cout << "pos " << oldpos(i,0) << " " << oldpos(i,1) << " " << oldpos(i,2) // << endl; } //generate .xyz file for gOpenMol to view coordinates pltfile=options.runid + ".xyz"; os.open(pltfile.c_str()); cout<<"writing to "<<pltfile<<endl; vector <string> atomlabels; sysprop->getAtomicLabels(atomlabels); os<<atomlabels.size()+mywalker->electronSize()<<endl; os<<endl; int spin_up=sysprop->nelectrons(0); //cout << "Up electrons "<<spin_up<<endl; for(unsigned int i=0; i<atomlabels.size(); i++){ Array1 <doublevar> pos(3); mywalker->getIonPos(i, pos); os<<atomlabels[i] <<" "<< pos(0) <<" "<<pos(1) <<" "<< pos(2)<<endl; } for(int j=0; j<mywalker->electronSize(); j++){ if (j<spin_up) os<<"Eu"; else os<<"Ed"; // mywalker->getElectronPos(j, pos); os<<" "<< oldpos(j,0)<<" "<<oldpos(j,1) <<" "<< oldpos(j,2)<<endl; } os.close(); if (!doublemove) { //calculate value of each molecular orbital at each grid point and store in an Array1 // grid values with x=fastest running variable, and z=slowest cout<<"calculating "<<D_array1(0)*D_array1(1)*D_array1(2) <<" grid points"<<endl; cout<<"for "<< plots.GetDim(0) <<" 3D projections of wavefunction"<<endl; count=0; xyz(0)=minmax(0); xyz(1)=minmax(2); xyz(2)=minmax(4); //init elec probe to xmin ymin zmin //Array1 <doublevar> oldpos(3) for(int i=0; i<plots.GetSize(); i++){ cout.width(3); cout <<"============================="<<plots(i) <<"==============================" <<endl; count=0; for(int xx=0; xx<D_array1(0);xx++){ xyz(0)=minmax(0)+xx*resolution_array(0); //move forward on x axis one resolution unit max_value=min_value=0.0; cout << "x "; cout.precision(5); cout.width(8); cout<< xyz(0); for(int yy=0; yy<D_array1(1);yy++){ xyz(1)=minmax(2)+yy*resolution_array(1); //move forward on y axis one resolution unit for(int zz=0;zz<D_array1(2);zz++){ xyz(2)=minmax(4)+zz*resolution_array(2); //move forward on z axis one resolution unit // mywalker->getElectronPos(plots(i), oldpos); mywalker->setElectronPos(plots(i)-1,xyz); //move elec#plots(i) to point specified by xyz wf->updateVal(wfdata, mywalker); //update wfdata wf->getVal(wfdata, 0, wfvals); //get wf value const doublevar cutoff=15; if(wfvals.amp(0,0)<cutoff) { grid(i,count)=wfvals.sign(0)*exp(wfvals.amp(0,0)); } else { //cut off the maximum value output so that there aren't overflow errors grid(i,count)=wfvals.sign(0)*exp(cutoff); } //grid(i,count)=exp(2.0*wfvals(0,1));//!square of wavefunction if (grid(i,count)>max_value) max_value=grid(i,count); if (grid(i,count)<min_value) min_value=grid(i,count); // cout << "grid " << grid(i,count)<< " " << xyz(0) << endl; count++; //index for cycling through grid points } } cout.setf(ios::scientific| ios:: showpos); cout <<", max. value "<<max_value<<", min. value "<<min_value<< endl; cout.unsetf(ios::scientific| ios:: showpos); } mywalker->setElectronPos(plots(i)-1, oldpos(plots(i)-1)); } //Loop through and generate plot files for each orbital requested if(plots.GetSize()<=0) error("Number of requested plots is not a positive number"); cout<<"saving data for "<<plots.GetSize()<<" 3D projections of wavefunction"<<endl; for(int i=0; i<plots.GetSize(); i++) { //output to file with orbital number in it char strbuff[40]; sprintf(strbuff, "%d", plots(i)); confile=pltfile = options.runid; confile += ".orb."; pltfile += ".orb."; pltfile += strbuff; confile += strbuff; pltfile += ".cube"; /*FIGURE OUT HOW TO CONVERT INT TO STRING*/ confile += ".xyz"; os.open(pltfile.c_str()); cout<<"writing to "<<pltfile<<endl; os << "QWalk nodes output\n"; os << "Wavefunction single scan with " << plots(i) <<" electron"<<endl; int natoms=sysprop->nIons(); os << " " << natoms+ mywalker->electronSize()-1 << " " << minmax(0) << " " << minmax(2) << " " << minmax(4) << endl; os << D_array1(0) << " " << resolution_array(0) << " 0.0000 0.0000" << endl; os << D_array1(1) << " 0.0000 " << resolution_array(1) << " 0.0000" << endl; os << D_array1(2) << " 0.0000 0.0000 " << resolution_array(2) << endl; Array1 <doublevar> pos(3); for(int at=0; at< natoms; at++) { mywalker->getIonPos(at,pos); os << " " << mywalker->getIonCharge(at) << " 0.0000 " << pos(0) <<" " << pos(1) << " " << pos(2) << endl; } for(int j=0; j<mywalker->electronSize(); j++){ if (j!=plots(i)-1){ if (j<spin_up) os<<" 3 0.0000 "; else os<<" 3 0.0000 "; os<< oldpos(j,0)<<" "<<oldpos(j,1)<<" "<< oldpos(j,2)<<endl; } } os.setf(ios::scientific); for(int j=0; j< D_array1(0)*D_array1(1)*D_array1(2); j++) { os <<setw(16)<<setprecision(8)<<grid(i,j); if(j%6 ==5) os << endl; } os << endl; os.unsetf(ios::scientific); os<<setprecision(6); os.close(); /* old plt file plots // http://www.csc.fi/gopenmol/developers/plt_format.phtml os<<"3 "; //rank=3 always os<<"2\n"; //dummy variable => "Orbital/density surface" //number of grid points for x, y, & z direction os <<D_array1(2)<<" "<<D_array1(1)<<" "<<D_array1(0)<<endl; os <<minmax(4)<<" "<<minmax(5)<<" "<<minmax(2)<<" "<<minmax(3) <<" "<<minmax(0)<<" "<<minmax(1)<<endl; for(int j=0; j<(D_array1(0)*D_array1(1)*D_array1(2)); j++) os<<grid(i,j)<<endl; os.close(); os.open(confile.c_str()); cout<<"writing to "<<confile<<endl; Array1 <doublevar> pos(3); sysprop->getAtomicLabels(atomlabels); os<<atomlabels.size()+ mywalker->electronSize()-1 <<endl; os << endl; for(unsigned int j=0; j<atomlabels.size();j++){ mywalker->getIonPos(j, pos); os<<atomlabels[j] <<" "<< pos(0) <<" "<<pos(1) <<" "<< pos(2)<<endl; } for(int j=0; j<mywalker->electronSize(); j++){ if (j!=plots(i)-1){ if (j<spin_up) os<<"Eu"; else os<<"Ed"; // mywalker->getElectronPos(j, pos); os<<" "<< oldpos(j,0)<<" "<<oldpos(j,1) <<" "<< oldpos(j,2)<<endl; } } os.close(); */ } } else { cout << "Using translation vector(s): "<<endl; for(int i=0;i<dxyz.GetDim(0);i++) cout<<"( "<<dxyz(i,0)<<" , "<<dxyz(i,1)<<" , "<<dxyz(i,2)<<" )"<<endl; for(int i=0; i<plots.GetSize(); i=i+2){ count=0; xyz(0)=minmax(0); xyz(1)=minmax(2); xyz(2)=minmax(4); //init elec probe to xmin ymin zmin //Array1 <doublevar> oldpos(3) cout.width(3); cout <<"============================="<<plots(i)<<" and "<<plots(i+1) <<"==============================" <<endl; for(int xx=0; xx<D_array1(0);xx++){ max_value=min_value=0.0; xyz(0)=minmax(0)+xx*resolution_array(0); xyz2(0)=xyz(0)+dxyz(i/2,0); cout << "x "; cout.precision(5); cout.width(8); cout<< xyz(0); for(int yy=0; yy<D_array1(1);yy++){ xyz(1)=minmax(2)+yy*resolution_array(1); xyz2(1)=xyz(1)+dxyz(i/2,1); for(int zz=0;zz<D_array1(2);zz++){ xyz(2)=minmax(4)+zz*resolution_array(2); xyz2(2)=xyz(2)+dxyz(i/2,2); // mywalker->getElectronPos(plots(i), oldpos); mywalker->setElectronPos(plots(i)-1,xyz);//move elec#plots(i) //to point specified by xyz mywalker->setElectronPos(plots(i+1)-1,xyz2);//move elec#plots(i) //to point specified by xyz wf->updateVal(wfdata, mywalker); //update wfdata wf->getVal(wfdata, 0, wfvals); //get wf value grid(i,count)=wfvals.sign(0)*exp(wfvals.amp(0,0)); //grid(i,count)=exp(2.0*wfvals(0,1));//!square of wavefunction // cout << "grid " << grid(i,count)<< " " << xyz(0) << endl; if (grid(i,count)>max_value) max_value=grid(i,count); if (grid(i,count)<min_value) min_value=grid(i,count); count++; //index for cycling through grid points } } cout.setf(ios::scientific| ios:: showpos); cout <<", max. value "<<max_value<<", min. value "<<min_value<< endl; cout.unsetf(ios::scientific| ios:: showpos); } mywalker->setElectronPos(plots(i)-1, oldpos(plots(i)-1)); mywalker->setElectronPos(plots(i+1)-1, oldpos(plots(i+1)-1)); } //Loop through and generate plot files for each orbital requested if(plots.GetSize()<=0) error("Number of requested plots is not a positive number"); cout<<"saving data for "<<plots.GetSize()<<" 3D projections of wavefunction"<<endl; for(int i=0; i<plots.GetSize(); i=i+2) { char strbuff2[40],strbuff[40]; //output to file with orbital number in it sprintf(strbuff, "%d", plots(i)); sprintf(strbuff2, "%d", plots(i+1)); confile=pltfile = options.runid; confile += ".orb."; pltfile += ".orb."; pltfile += strbuff; confile += strbuff; pltfile += "with"; confile += "with"; pltfile += strbuff2; confile += strbuff2; pltfile += ".cube"; /*FIGURE OUT HOW TO CONVERT INT TO STRING*/ confile += ".xyz"; os.open(pltfile.c_str()); cout<<"writing to "<<pltfile<<endl; os << "GOS nodes output\n"; os << "Wave function double scan with "<< plots(i) <<" & "<<plots(i+1)<<" electrons"<< endl; int natoms=sysprop->nIons(); os << " " << natoms + mywalker->electronSize()-2 << " " << minmax(0) << " " << minmax(2) << " " << minmax(4) << endl; os << D_array1(0) << " " << resolution_array(0) << " 0.0000 0.0000" << endl; os << D_array1(1) << " 0.0000 " << resolution_array(1) << " 0.0000" << endl; os << D_array1(2) << " 0.0000 0.0000 " << resolution_array(2) << endl; Array1 <doublevar> pos(3); for(int at=0; at< natoms; at++) { mywalker->getIonPos(at,pos); os << " " << mywalker->getIonCharge(at) << " 0.0000 " << pos(0) <<" " << pos(1) << " " << pos(2) << endl; } for(int j=0; j<mywalker->electronSize(); j++){ if ((j!=plots(i)-1)&&(j!=plots(i+1)-1)){ if (j<spin_up) os<<" 3 0.0000 "; else os<<" 3 0.0000 "; os<< oldpos(j,0)<<" "<<oldpos(j,1)<<" "<< oldpos(j,2)<<endl; } } os.setf(ios::scientific); for(int j=0; j< D_array1(0)*D_array1(1)*D_array1(2); j++) { os << setw(16) << setprecision(8) << grid(i,j); if(j%6 ==5) os << endl; } os << endl; os.unsetf(ios::scientific); os<<setprecision(6); os.close(); /* old plot to plt file version // http://www.csc.fi/gopenmol/developers/plt_format.phtml os<<"3 "; //rank=3 always os<<"2\n"; //dummy variable => "Orbital/density surface" //number of grid points for x, y, & z direction os <<D_array1(2)<<" "<<D_array1(1)<<" "<<D_array1(0)<<endl; os <<minmax(4)<<" "<<minmax(5)<<" "<<minmax(2)<<" "<<minmax(3) <<" "<<minmax(0)<<" "<<minmax(1)<<endl; for(int j=0; j<(D_array1(0)*D_array1(1)*D_array1(2)); j++) os<<grid(i,j)<<endl; os.close(); os.open(confile.c_str()); cout<<"writing to "<<confile<<endl; Array1 <doublevar> pos(3); sysprop->getAtomicLabels(atomlabels); os<<atomlabels.size()+ mywalker->electronSize()-2 <<endl; os << endl; for(unsigned int j=0; j<atomlabels.size();j++){ mywalker->getIonPos(j, pos); os<<atomlabels[j] <<" "<< pos(0) <<" "<<pos(1) <<" "<< pos(2)<<endl; } for(int j=0; j<mywalker->electronSize(); j++){ if ((j!=plots(i)-1)&&(j!=plots(i+1)-1)){ if (j<spin_up) os<<"Eu"; else os<<"Ed"; // mywalker->getElectronPos(j, pos); os<<" "<< oldpos(j,0)<<" "<<oldpos(j,1) <<" "<< oldpos(j,2)<<endl; } } os.close(); */ } } cout <<"End of Nodes Method"<<endl; }
void pulsesequence() { // Define Variables and Objects and Get Parameter Values CP hx = getcp("HX",0.0,0.0,0,1); strncpy(hx.fr,"dec",3); strncpy(hx.to,"obs",3); putCmd("frHX='dec'\n"); putCmd("toHX='obs'\n"); PBOXPULSE shca = getpboxpulse("shcaX",0,1); strncpy(shca.ch,"obs",3); putCmd("chXshca ='obs'\n"); PBOXPULSE shco = getpboxpulse("shcoX",0,1); strncpy(shco.ch,"obs",3); putCmd("chXshco ='obs'\n"); PBOXPULSE shcaco = combine_PBOXPULSE(shca,shco,0,1); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); DSEQ mix = getdseq("Hmix"); strncpy(mix.t.ch,"dec",3); putCmd("chHmixtppm='dec'\n"); strncpy(mix.s.ch,"dec",3); putCmd("chHmixspinal='dec'\n"); double shcacolen = (shcaco.pw + 2.0*shcaco.t2)/2.0; double d22 = d2/2.0; // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwH90") + getval("tHX") + 2.0*shcaco.pw + 4.0*getval("pwX90"); d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = d2_ + getval("tZF") - getval("pwX90") + getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = d2_ + getval("tZF") - getval("pwX90") + getval("rd") + getval("ad") + at; d.c3 = d.c3 + (!strcmp(mix.seq,"tppm")); d.c3 = d.c3 + ((!strcmp(mix.seq,"tppm")) && (mix.t.a > 0.0)); d.t3 = 2.0*getval("taua") + 2.0*getval("taub") + 2.0*shcaco.t1 + 2.0*shcaco.t2 - 4.0*shcacolen - 2.5*getval("pwX90") - 6.0e-6; d.c4 = d.c4 + (!strcmp(mix.seq,"spinal")); d.c4 = d.c4 + ((!strcmp(mix.seq,"spinal")) && (mix.s.a > 0.0)); d.t4 = 2.0*getval("taua") + 2.0*getval("taub") + 2.0*shcaco.t1 + 2.0*shcaco.t2 - 4.0*shcacolen - 2.5*getval("pwX90") - 6.0e-6; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Up 2D int errval = (int) ((getval("taua") - shcacolen)*2.0*sw1); if ((getval("taua") - ni/(2.0*sw1) - shcacolen) < 0.0) { text_error("Error:ni is too large. Make ni equal to %d or less.\n",errval); psg_abort(1); } // Set Phase Tables settable(phH90,4,table1); settable(phXhx,4,table2); settable(phHhx,4,table3); settable(ph1Xshcaco,4,table4); settable(ph1X90,4,table5); settable(ph2X90,4,table6); settable(ph2Xshcaco,4,table7); settable(ph3X90,4,table8); settable(ph4X90,4,table9); settable(phRec,4,table10); setreceiver(phRec); // States Acquisition if (phase1 == 2) tsadd(phXhx,3,4); // Begin Sequence txphase(phXhx); decphase(phH90); obspwrf(getval("aXhx")); decpwrf(getval("aH90")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H to X Cross Polarization decrgpulse(getval("pwH90"),phH90,0.0,0.0); decphase(phHhx); _cp_(hx,phHhx,phXhx); decphase(zero); // Begin F1 Refocused INEPT _dseqon(mix); txphase(ph1Xshcaco); obspwrf(shcaco.a); delay(getval("taua") - d22 - shcacolen); _pboxpulse(shcaco,ph1Xshcaco); obsblank(); obspower(getval("tpwr")); delay(3.0e-6); obsunblank(); obsunblank(); txphase(ph1X90); obspwrf(getval("aX90")); delay(getval("taua") + d22 - shcacolen - getval("pwX90") - 3.0e-6); rgpulse(getval("pwX90"),ph1X90,0.0,0.0); rgpulse(getval("pwX90"),ph2X90,0.0,0.0); txphase(ph2Xshcaco); obspwrf(shcaco.a); obsunblank(); delay(getval("taub") - shcacolen - getval("pwX90")); _pboxpulse(shcaco,ph2Xshcaco); obsblank(); obspower(getval("tpwr")); delay(3.0e-6); obsunblank(); txphase(ph3X90); obspwrf(getval("aX90")); obsunblank(); delay(getval("taub") - shcacolen - getval("pwX90")/2.0 - 3.0e-6); rgpulse(getval("pwX90"),ph3X90,0.0,0.0); txphase(ph4X90); obsunblank(); _dseqoff(mix); _dseqon(dec); delay(getval("tZF") - getval("pwX90")); rgpulse(getval("pwX90"),ph4X90,0.0,0.0); // Begin Acquisition obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }
pulsesequence() { // Define Variables and Objects and Get Parameter Values CP hy = getcp("HY",0.0,0.0,0,1); strncpy(hy.fr,"dec",3); strncpy(hy.to,"dec2",4); putCmd("frHY='dec'\n"); putCmd("toHY='dec2'\n"); PBOXPULSE shca = getpboxpulse("shcaX",0,1); strncpy(shca.ch,"obs",3); putCmd("chXshca ='obs'\n"); PBOXPULSE sh = getpboxpulse("shY",0,1); strncpy(sh.ch,"dec2",4); putCmd("chYsh ='dec2'\n"); PBOXPULSE shco = getpboxpulse("shcoX",0,1); strncpy(shco.ch,"obs",3); putCmd("chXshco ='obs'\n"); DSEQ dec = getdseq("H"); strncpy(dec.t.ch,"dec",3); putCmd("chHtppm='dec'\n"); strncpy(dec.s.ch,"dec",3); putCmd("chHspinal='dec'\n"); DSEQ mix = getdseq("Hmix"); strncpy(mix.t.ch,"dec",3); putCmd("chHmixtppm='dec'\n"); strncpy(mix.s.ch,"dec",3); putCmd("chHmixspinal='dec'\n"); double pwsim = getval("pwX90"); if (getval("pwY90") > getval("pwX90")) pwsim = getval("pwY90"); pwsim = pwsim/2.0; double shcalen = (shca.pw + 2.0*shca.t2)/2.0; double shlen = (sh.pw + 2.0*sh.t2)/2.0; double shsim = shcalen; double simpw = shca.pw; double simt1 = shca.t1; double simt2 = shca.t2; if (shlen > shcalen) { shsim = shlen; simpw = sh.pw; simt1 = sh.t1; simt2 = sh.t2; } double shcolen = (shco.pw + 2.0*shco.t2)/2.0; double d22 = d2/2.0; // Set Constant-time Period for d2. if (d2_index == 0) d2_init = getval("d2"); double d2_ = (ni - 1)/sw1 + d2_init; putCmd("d2acqret = %f\n",roundoff(d2_,12.5e-9)); putCmd("d2dwret = %f\n",roundoff(1.0/sw1,12.5e-9)); //-------------------------------------- // Copy Current Parameters to Processed //------------------------------------- putCmd("groupcopy('current','processed','acquisition')"); // Dutycycle Protection DUTY d = init_dutycycle(); d.dutyon = getval("pwH90") + getval("tHY") + 2.0* simpw + shco.pw; d.dutyoff = d1 + 4.0e-6; d.c1 = d.c1 + (!strcmp(dec.seq,"tppm")); d.c1 = d.c1 + ((!strcmp(dec.seq,"tppm")) && (dec.t.a > 0.0)); d.t1 = d2_ + getval("rd") + getval("ad") + at; d.c2 = d.c2 + (!strcmp(dec.seq,"spinal")); d.c2 = d.c2 + ((!strcmp(dec.seq,"spinal")) && (dec.s.a > 0.0)); d.t2 = d2_ + getval("rd") + getval("ad") + at; d.c3 = d.c3 + (!strcmp(mix.seq,"tppm")); d.c3 = d.c3 + ((!strcmp(mix.seq,"tppm")) && (mix.t.a > 0.0)); d.t3 = 2.0*getval("taua") + 2.0*getval("taub") - 2.0*shsim - shcolen + 2.0*simt1 + 2.0*simt2 - pwsim - 2.0*shsim; d.c4 = d.c4 + (!strcmp(mix.seq,"spinal")); d.c4 = d.c4 + ((!strcmp(mix.seq,"spinal")) && (mix.s.a > 0.0)); d.t4 = 2.0*getval("taua") + 2.0*getval("taub") - 2.0*shsim - shcolen + 2.0*simt1 + 2.0*simt2 - pwsim - 2.0*shsim; d = update_dutycycle(d); abort_dutycycle(d,10.0); // Set Up 2D int errval = (int) ((getval("taua") - shsim)*2.0*sw1); if ((getval("taua") - ni/(2.0*sw1) - shsim) < 0.0) { text_error("Error:ni is too large. Make ni equal to %d or less.\n",errval); psg_abort(1); } // Set Phase Tables settable(phH90,4,table1); settable(phHhy,4,table2); settable(phYhy,4,table3); settable(ph1Xshca,4,table4); settable(ph1Ysh,4,table5); settable(phXshco,4,table6); settable(phX90,4,table7); settable(phY90,4,table8); settable(ph2Xshca,4,table9); settable(ph2Ysh,4,table10); settable(phRec,4,table11); setreceiver(phRec); // States Acquisition if (phase1 == 2) tsadd(phYhy,1,4); // Begin Sequence txphase(ph1Xshca); decphase(phH90); dec2phase(phYhy); obspwrf(getval("aXshca")); decpwrf(getval("aH90")); dec2pwrf(getval("aYhy")); obsunblank(); decunblank(); _unblank34(); delay(d1); sp1on(); delay(2.0e-6); sp1off(); delay(2.0e-6); // H to Y Cross Polarization decrgpulse(getval("pwH90"),phH90,0.0,0.0); decphase(phHhy); _cp_(hy,phHhy,phYhy); decphase(zero); // Begin F1 INEPT _dseqon(mix); dec2phase(ph1Ysh); dec2pwrf(getval("aYsh")); delay(getval("taua") - d22 - shsim); _pboxsimpulse(shca,sh,ph1Xshca,ph1Ysh); obsblank(); obspower(getval("tpwr")); dec2power(getval("dpwr2")); delay(3.0e-6); obsunblank(); if (d22 < (shcolen + pwsim)) { txphase(phX90); dec2phase(phY90); obspwrf(getval("aX90")); dec2pwrf(getval("aY90")); delay(getval("taua") + d22 - shsim - pwsim - 3.0e-6); } else { txphase(phXshco); obspwrf(getval("aXshco")); delay(getval("taua") - shsim - shcolen - 3.0e-6); _pboxpulse(shco,phXshco); obsblank(); obspower(getval("tpwr")); delay(3.0e-6); obsunblank(); txphase(phX90); dec2phase(phY90); obspwrf(getval("aX90")); dec2pwrf(getval("aY90")); delay(d22 - shcolen - pwsim - 3.0e-6); } sim3pulse(getval("pwX90"),0.0,getval("pwY90"),phX90,zero,phY90,0.0,0.0); obsunblank(); dec2unblank(); txphase(ph2Xshca); dec2phase(ph2Ysh); delay(getval("taub") - pwsim - shsim); _pboxsimpulse(shca,sh,ph2Xshca,ph2Ysh); obsblank(); obspower(getval("tpwr")); dec2power(getval("dpwr2")); delay(3.0e-6); obsunblank(); delay(getval("taub") - shsim - 3.0e-6); _dseqoff(mix); // Begin Acquisition _dseqon(dec); obsblank(); _blank34(); delay(getval("rd")); startacq(getval("ad")); acquire(np, 1/sw); endacq(); _dseqoff(dec); obsunblank(); decunblank(); _unblank34(); }