void DualTask(void* pData) { try{ trace_log(DBG, "Start issue Transaction!"); XSVC_LIST *pNode =(XSVC_LIST*)pData; Dual(pNode); if(pNode->rqst->data) { delete pNode->rqst->data; pNode->rqst->data=NULL; } if(pNode->rqst) { delete pNode->rqst; pNode->rqst=NULL; } if(pNode) { delete pNode;/**< 在T_CUP_SX_POSP创建 */ pNode=NULL; } }catch(...){ trace_log(SYS, "Error in DualTask()"); return; } }
int main(int argc, char** argv) { NcError error(NcError::silent_nonfatal); try { // Resolution int nResolution; // Dual mesh bool fDual; // Output filename std::string strOutputFile; // Parse the command line BeginCommandLine() CommandLineInt(nResolution, "res", 10); CommandLineBool(fDual, "dual"); CommandLineString(strOutputFile, "file", "outICOMesh.g"); ParseCommandLine(argc, argv); EndCommandLine(argv) // Generate Mesh AnnounceBanner(); AnnounceStartBlock("Generating Mesh"); Mesh mesh; GenerateIcosahedralQuadGrid(nResolution, mesh.nodes, mesh.faces); AnnounceEndBlock("Done"); // Generate the dual grid if (fDual) { Dual(mesh); } // Output the mesh AnnounceStartBlock("Writing Mesh to file"); Announce("Mesh size: Nodes [%i] Elements [%i]", mesh.nodes.size(), mesh.faces.size()); mesh.Write(strOutputFile); AnnounceEndBlock("Done"); } catch(Exception & e) { std::cout << e.ToString() << std::endl; } }
// add using dual numbers // combine diffeq and incorporation for direct RedTrace computation void DerivativeRedTrace(float *red_out, float *ival_offset, float *da_offset, float *dk_offset, int npts, float *deltaFrameSeconds, float *deltaFrame, float *nuc_rise_ptr, int SUB_STEPS, int my_start, Dual A, float SP, Dual kr, float kmax, float d, float sens, float gain, float tauB, PoissonCDFApproxMemo *math_poiss) { int i; Dual totocc, totgen; // mixed_poisson_struct mix_ctrl; MixtureMemo mix_memo; Dual pact,pact_new; Dual c_dntp_top, c_dntp_bot; Dual hplus_events_sum, hplus_events_current; // mean events per molecule, cumulative and current Dual ldt; Dual Ival; Dual One(1.0); Dual Zero(0.0); Dual Half(0.5); Dual xSP(SP); Dual xkmax(kmax); Dual xd(d); Dual xA = mix_memo.Generate(A,math_poiss); //xA.Dump("xA"); //A = InitializeMixture(&mix_ctrl,A,MAX_HPLEN); // initialize Poisson with correct amplitude which maxes out at MAX_HPLEN mix_memo.ScaleMixture(SP); //ScaleMixture(&mix_ctrl,SP); // scale mixture fractions to proper number of molecules pact = Dual(mix_memo.total_live); // active polymerases // wrong??? //pact.Dump("pact"); //Dual pact_zero = pact; totocc = xSP*xA; // how many hydrogens we'll eventually generate //totocc.Dump("totocc"); totgen = totocc; // number remaining to generate //totgen.Dump("totgen"); c_dntp_bot = Zero; // concentration of dNTP in the well c_dntp_top = Zero; // concentration at top hplus_events_sum = hplus_events_current = Zero; // Events per molecule memset(ival_offset,0,sizeof(float[my_start])); // zero the points we don't compute memset(da_offset,0,sizeof(float[my_start])); // zero the points we don't compute memset(dk_offset,0,sizeof(float[my_start])); // zero the points we don't compute Dual scaled_kr = kr*Dual(n_to_uM_conv)/xd; // convert molecules of polymerase to active concentraction Dual half_kr = kr *Half; // for averaging // kr.Dump("kr"); //scaled_kr.Dump("scaled_kr"); //half_kr.Dump("half_kr"); // first non-zero index of the computed [dNTP] array for this nucleotide int c_dntp_top_ndx = my_start*SUB_STEPS; Dual c_dntp_bot_plus_kmax = Dual(1.0/kmax); Dual c_dntp_old_effect = Zero; Dual c_dntp_new_effect = Zero; Dual cur_gen(0.0); Dual equilibrium(0.0); int st; // trace variables Dual old_val = Zero; Dual cur_val = Zero; Dual run_sum = Zero; Dual half_dt = Zero; Dual TauB(tauB); Dual SENS(sens); memset(red_out,0,sizeof(float[my_start])); for (i=my_start;i < npts;i++) { // Do one prediction time step if (totgen.a > 0.0) { // need to calculate incorporation ldt = (deltaFrameSeconds[i]/SUB_STEPS); // multiply by half_kr out here, because I'm going to use it twice? ldt *= half_kr; // scale time by rate out here //ldt.Dump("ldt"); for (st=1; (st <= SUB_STEPS) && (totgen.a > 0.0);st++) { c_dntp_bot.a = nuc_rise_ptr[c_dntp_top_ndx]; c_dntp_top_ndx++; // calculate denominator equilibrium = c_dntp_bot_plus_kmax; equilibrium *= pact; equilibrium *= scaled_kr; equilibrium += One; c_dntp_bot /= equilibrium; //c_dntp_bot.Dump("c_dntp_bot"); // the level at which new nucs are used up as fast as they diffuse in c_dntp_bot_plus_kmax.Reciprocal(c_dntp_bot + xkmax); // scale for michaelis-menten kinetics, assuming nucs are limiting factor //c_dntp_bot_plus_kmax.Dump("plus_kmax"); // Now compute effect of concentration on enzyme rate c_dntp_old_effect = c_dntp_new_effect; c_dntp_new_effect = c_dntp_bot; c_dntp_new_effect *= c_dntp_bot_plus_kmax; // current effect of concentration on enzyme rate //c_dntp_new_effect.Dump("c_dntp_new"); // update events per molecule hplus_events_current = c_dntp_old_effect; hplus_events_current += c_dntp_new_effect; hplus_events_current *= ldt; //hplus_events_current.Dump("current"); // events per molecule is average rate * time of rate hplus_events_sum += hplus_events_current; //hplus_events_sum.Dump("sum"); // how many active molecules left at end of time period given poisson process with total intensity of events // exp(-t) * (1+t+t^2/+t^3/6+...) where we interpolate between polynomial lengths by A // exp(-t) ( 1+... + frac*(t^k/k!)) where k = ceil(A-1) and frac = A-floor(A), for A>=1 pact_new = mix_memo.GetStep(hplus_events_sum); //pact_new = pact_zero; //pact_new.Dump("pact_new"); // how many hplus were generated // reuse pact for average // reuse hplus-events_current for total events pact += pact_new; pact *= Half; // average number of molecules //hplus_events_current *= pact; // events/molecule *= molecule is total events totgen -= pact*hplus_events_current; // active molecules * events per molecule //totgen.Dump("totgen"); pact = pact_new; // update to current number of molecules //pact.Dump("pact"); } if (totgen.a < 0.0) totgen = Zero; } Ival = totocc; Ival -= totgen; ival_offset[i] = Ival.a; Ival *= SENS; // convert from hydrogen to counts // Now compute trace // trace half_dt = deltaFrame[i]*0.5; // calculate new value Ival *= TauB; cur_val = Ival; cur_val -= run_sum; old_val *= half_dt; // update cur_val -= old_val; cur_val /= (TauB+half_dt); // update run sum run_sum += old_val; // reuse update run_sum += cur_val*half_dt; old_val = cur_val; // set for next value //cur_val *= gain; // gain=1.0 always currently red_out[i] = cur_val.a; da_offset[i] = cur_val.da; dk_offset[i] = cur_val.dk; // now we have done one prediction time step } }