NT get_signed_area() const { NT unity(1.0); NT half(1.0/2.0); NT area = half * determinant(p0.x(), p0.y(), unity, p1.x(), p1.y(), unity, p2.x(), p2.y(), unity); return area; }
int main (int argc, char ** argv) { std::vector<shyft::helper::EffInfo> s; s.push_back( shyft::helper::EffInfo(0, 0.50, 0) ); s.push_back( shyft::helper::EffInfo(1, 0.10, 1) ); s.push_back( shyft::helper::EffInfo(2, 0.05, 2) ); s.push_back( shyft::helper::EffInfo(3, 0.50, 0) ); shyft::helper::EffInfo unity( -1, 1.0, 0); std::sort( s.begin(), s.end() ); std::cout << "Looking for these efficiencies: " << std::endl; copy(s.begin(), s.end(), std::ostream_iterator<shyft::helper::EffInfo>(std::cout, " ")); std::cout << std::endl; double sum = 0.0; // Loop over all the possible "N_jets" for ( std::size_t k = 0; k <= s.size(); ++k ) { std::cout << " ------ k = " << k << std::endl; // Loop over all combinations double ksum = 0.0; do { // Dump to the screen copy(s.begin(), s.end(), std::ostream_iterator<shyft::helper::EffInfo>(std::cout, " ")); // Get the "tag" bit, from "begin" to "k" shyft::helper::EffInfo ni = accumulate(s.begin(), s.begin() + k, unity, std::multiplies<shyft::helper::EffInfo>()); // Get the "untag" bit, from "k" to "end" shyft::helper::EffInfo nj = accumulate(s.begin()+k, s.end(), unity, shyft::helper::oneminusmultiplies<shyft::helper::EffInfo>()); // The product is the total probability to tag exact k jets. sum += ni.eff * nj.eff; ksum += ni.eff * nj.eff; std::cout << " tagprob = " << ni.eff << ", untagprob = " << nj.eff << ", prod = " << ni.eff*nj.eff << std::endl; } while(shyft::helper::next_combination(s.begin(),s.begin() + k, s.end())); std::cout << " Sum for k = " << k << " = " << ksum << std::endl; } // Print out the total std::cout << "Total = " << sum << std::endl; }
int main(int argc, char *argv[]){ Unity unity(argc, argv); sleep(5); while(ros::ok()){ unity.statusUpdate(); std::vector<unsigned int> motions = unity.detectMotionId(); for(int i=0; i < motions.size(); i++){ switch(motions[i]){ case 1: //hand up right unity.motor(40, 20); break; case 2: //hand up left unity.motor(20, 40); break; } } } }
void newmtrx(QSP_ARG_DECL const char *s,int dim) { Data_Obj *mp; if( dim <= 1 ){ WARN("bad dimension"); return; } mp=dobj_of(QSP_ARG s); if( mp!=(NO_OBJ) ){ WARN("name in use already"); return; } mp=make_obj(QSP_ARG s,1,dim,dim,1,prec_for_code(PREC_SP)); if( mp == NO_OBJ ){ WARN("couldn't create new matrix"); return; } unity(mp); }
void SpinAdapted::operatorfunctions::TensorTraceElement(const SpinBlock *ablock, const Baseoperator<Matrix>& a, const SpinBlock *cblock, const StateInfo *cstateinfo, Baseoperator<Matrix>& c, Matrix& cel, int cq, int cqprime, double scale) { if (fabs(scale) < TINY) return; assert(c.allowed(cq, cqprime)); int aq, aqprime, bq, bqprime, bstates; const char conjC = (ablock == cblock->get_leftBlock()) ? 'n' : 't'; const std::vector<int> oldToNewI = cstateinfo->oldToNewState.at(cq); const std::vector<int> oldToNewJ = cstateinfo->oldToNewState.at(cqprime); const StateInfo* rS = cstateinfo->rightStateInfo, *lS = cstateinfo->leftStateInfo; int rowstride =0, colstride = 0; for (int oldi =0; oldi < oldToNewI.size(); oldi++) { colstride = 0; for (int oldj = 0; oldj < oldToNewJ.size(); oldj++) { if (conjC == 'n') { aq = cstateinfo->leftUnMapQuanta[ oldToNewI[oldi] ]; aqprime = cstateinfo->leftUnMapQuanta[ oldToNewJ[oldj] ]; bq = cstateinfo->rightUnMapQuanta[ oldToNewI[oldi] ]; bqprime = cstateinfo->rightUnMapQuanta[ oldToNewJ[oldj] ]; bstates = cstateinfo->rightStateInfo->getquantastates(bq); } else { aq = cstateinfo->rightUnMapQuanta[ oldToNewI[oldi] ]; aqprime = cstateinfo->rightUnMapQuanta[ oldToNewJ[oldj] ]; bq = cstateinfo->leftUnMapQuanta[ oldToNewI[oldi] ]; bqprime = cstateinfo->leftUnMapQuanta[ oldToNewJ[oldj] ]; bstates = cstateinfo->leftStateInfo->getquantastates(bq); } if (a.allowed(aq, aqprime) && (bq == bqprime)) { DiagonalMatrix unitMatrix(bstates); unitMatrix = 1.; Matrix unity(bstates, bstates); unity = unitMatrix; if (conjC == 'n') { double scaleb = dmrginp.get_ninej()(lS->quanta[aqprime].get_s().getirrep() , rS->quanta[bqprime].get_s().getirrep(), cstateinfo->quanta[cqprime].get_s().getirrep(), a.get_spin().getirrep(), 0, c.get_spin().getirrep(), lS->quanta[aq].get_s().getirrep() , rS->quanta[bq].get_s().getirrep(), cstateinfo->quanta[cq].get_s().getirrep()); scaleb *= Symmetry::spatial_ninej(lS->quanta[aqprime].get_symm().getirrep() , rS->quanta[bqprime].get_symm().getirrep(), cstateinfo->quanta[cqprime].get_symm().getirrep(), a.get_symm().getirrep(), 0, c.get_symm().getirrep(), lS->quanta[aq].get_symm().getirrep() , rS->quanta[bq].get_symm().getirrep(), cstateinfo->quanta[cq].get_symm().getirrep()); MatrixTensorProduct (a.operator_element(aq, aqprime), a.conjugacy(), scale, unity, 'n', scaleb, cel, rowstride, colstride); } else { double scaleb = dmrginp.get_ninej()(lS->quanta[bqprime].get_s().getirrep(), rS->quanta[aqprime].get_s().getirrep() , cstateinfo->quanta[cqprime].get_s().getirrep(), 0, a.get_spin().getirrep(), c.get_spin().getirrep(), lS->quanta[bq].get_s().getirrep(), rS->quanta[aq].get_s().getirrep() , cstateinfo->quanta[cq].get_s().getirrep()); scaleb *= Symmetry::spatial_ninej(lS->quanta[bqprime].get_symm().getirrep() , rS->quanta[aqprime].get_symm().getirrep(), cstateinfo->quanta[cqprime].get_symm().getirrep(), 0, a.get_symm().getirrep(), c.get_symm().getirrep(), lS->quanta[bq].get_symm().getirrep() , rS->quanta[aq].get_symm().getirrep(), cstateinfo->quanta[cq].get_symm().getirrep()); if (a.get_fermion() && IsFermion (cstateinfo->leftStateInfo->quanta[bqprime]) ) scaleb *= -1.; MatrixTensorProduct (unity, 'n', scaleb, a.operator_element(aq, aqprime), a.conjugacy(), scale, cel, rowstride, colstride); } } colstride += cstateinfo->unCollectedStateInfo->quantaStates[ oldToNewJ[oldj] ]; } rowstride += cstateinfo->unCollectedStateInfo->quantaStates[ oldToNewI[oldi] ]; } }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "readGravitationalAcceleration.H" #include "createFields.H" #include "createMRFZones.H" #include "createFvOptions.H" #include "initContinuityErrs.H" #include "readTimeControls.H" #include "CourantNos.H" #include "setInitialDeltaT.H" //for testing only with a constant interpahse mass transfer term dimensionedScalar gamma_LV ("gamma_LV", dimensionSet (1,-3,-1,0,0,0,0), scalar(0.000)); dimensionedScalar gamma_VL ("gamma_LV", dimensionSet (1,-3,-1,0,0,0,0), scalar(0.000)); // pipeline dimension dimensionedScalar Dh ("Dh", dimensionSet (0,1,0,0,0,0,0), scalar(0.233)); // initial wall temperature dimensionedScalar TwallInit ("TwallInit", dimensionSet (0,0,0,1,0,0,0), scalar(289.43)); // friction factor scalar frictionFactor = 0.005; //my volScalarField declaration #include "myVolScalar.H" //quasi-one-dimensional flow setup #include "changeArea.H" //load refprop thermodynamic library #include "refpropLibLoading.H" //initialise the wall temperature Twall = TwallInit; //dummy vector vector unity(1,0,0); //start of the loop pimpleControl pimple(mesh); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { #include "readTimeControls.H" #include "CourantNos.H" #include "setDeltaT.H" // interface mass and heat transfer #include "massAndEnergyTransfer.H" // update boundary conditions (NSCBC) #include "NSCBCpuncture.H" // update wall flux (heat transfer to the vapour phase from the wall) #include "transportProperties.H" // runtime time output runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { fluid.solve(); fluid.correct(); // interface mass and heat transfer //#include "massAndEnergyTransfer.H" // update boundary conditions p.boundaryField()[patchID] == p_ghost_update2; U1.boundaryField()[patchID] == vector(U_ghost_update2,0,0); U2.boundaryField()[patchID] == vector(U_ghost_update2,0,0); //thermo1.T().boundaryField()[patchID] == T_ghost_update; //thermo2.T().boundaryField()[patchID] == T_ghost_update; //alpha1.boundaryField()[patchID] == alpha1_ghost_update; //alpha2.boundaryField()[patchID] == 1.0 - alpha1_ghost_update; U_bulk = mag(alpha1*U1+alpha2*U2); rho_bulk = alpha1*rho1+alpha2*rho2; psi_bulk =1.0/(alpha1/thermo1.psi()+alpha2/thermo2.psi()); volScalarField contErr1 ( fvc::ddt(alpha1, rho1) + fvc::div(alphaRhoPhi1) - (fvOptions(alpha1, rho1)&rho1) // fvOptions are the runtime semi-implicit source term + alpha1*rho1*mag(U1)*areaSource - gammaV ); volScalarField contErr2 ( fvc::ddt(alpha2, rho2) + fvc::div(alphaRhoPhi2) - (fvOptions(alpha2, rho2)&rho2) + alpha2*rho2*mag(U2)*areaSource - gammaL ); // update friction source term Fv = - scalar(2)*frictionFactor*alpha1*rho1*mag(U1)*mag(U1)/Dh; Fl = - scalar(2)*frictionFactor*alpha2*rho2*mag(U2)*mag(U2)/Dh; #include "UEqns.H" // update friction source term for energy balance U_bulk = mag(alpha1*U1+alpha2*U2); FvU_bulk = U_bulk*Fv; FlU_bulk = U_bulk*Fl; #include "EEqns.H" // --- Pressure corrector loop while (pimple.correct()) { #include "pEqn.H" } #include "DDtU.H" if (pimple.turbCorr()) { fluid.correctTurbulence(); } } #include "write.H" //const volScalarField& test = alpha1_.db().lookupObject<volScalarField>("flowAreaGrad"); //loop over all cells: //forAll(mesh.C(), cellI) //{ //Info << "******* CellID: " << cellI << "*******"<< endl; //Getting list of all faces of current cell //const labelList& faces = mesh.cells()[cellI]; //loop over all faces of current cell //forAll( faces, faceI ) //{ //if (mesh.isInternalFace(faces[faceI])) //{ //Info << "internal faceI: " << faceI << " mesh.Sf()[faceI]: " << -mesh.Sf()[faceI] << " mesh.magSf()[faceI]: " << mesh.magSf()[faceI] << endl; //} //else //{ //Info << "boundary faceI: " << faceI << " mesh.Sf()[faceI]: " << -mesh.Sf()[faceI] << " mesh.magSf()[faceI]: " << mesh.magSf()[faceI] << endl; //} //} //move on to next face //Info << " " << endl; //}//move on to next cell Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n\n" << endl; } Info<< "End\n" << endl; return 0; }
void SceneObjectImplementation::rotate(int degrees) { Vector3 unity(0, 1, 0); direction.rotate(unity, degrees); }