Ejemplo n.º 1
0
void uv_orb::fillDeltagrids(const std::string& file){

	E_delta.clear();L_delta.clear();Delta.clear();
    E_delta = create_range(E0,Emax,NE);
    L_delta = std::vector<VecDoub>(NE,VecDoub(NL,0.));
    Delta = std::vector<VecDoub>(NE,VecDoub(NL,0.));
    #pragma omp parallel for schedule (dynamic)
    for(int i=0; i<NE;i++){
        double R = Pot->R_E(E_delta[i]);
        for(double j=0;j<NL;j++){
            L_delta[i][j] = Pot->L_circ(R)*(j*0.8/(double)(NL-1)+0.001);
            find_best_delta DD(Pot, E_delta[i], L_delta[i][j]);
            Delta[i][j]=DD.delta(R*.9);
            if(Delta[i][j]<0. or Delta[i][j]!=Delta[i][j])
            	Delta[i][j]=R/5.;
            std::cerr<<"DeltaGrid: "
            	<<OUTPUT(E_delta[i])
            	<<OUTPUT(L_delta[i][j])
            	<<OUTPUT(R)
            	<<OUTPUTE(Delta[i][j]);
        }
    }
    std::cerr<<"DeltaGrid calculated: NE = "<<NE<<", NL = "<<NL<<std::endl;

    std::ofstream outfile; outfile.open(file);
	for(int i=0;i<NE;++i)
		for(int j=0;j<NL;++j)
		outfile<<E_delta[i]<<" "<<L_delta[i][j]<<" "<<Delta[i][j]<<std::endl;
	outfile.close();

}
Ejemplo n.º 2
0
void uv_orb::readDeltagrids(const std::string& file){
	std::ifstream infile; infile.open(file);
	if(!infile.is_open())std::cerr<<"Problem: "<<file<<" doesn't exist."<<std::endl;
	E_delta = VecDoub(NE,0.);
	L_delta = std::vector<VecDoub>(NE,VecDoub(NL,0.));
	Delta = L_delta;
	for(int i=0;i<NE;++i) infile>>E_delta[i];
	for(int i=0;i<NE;++i)for(int j=0;j<NL;++j) infile>>L_delta[i][j];
	for(int i=0;i<NE;++i)for(int j=0;j<NL;++j) infile>>Delta[i][j];
	infile.close();
}
Ejemplo n.º 3
0
MultipoleExpansion::MultipoleExpansion(Density *rho,int NR, int NA, int LMAX1, int MMAX1, double a0, double rmin, double rmax,
    bool axisymmetric, bool triaxial, bool flip, double err)
    :rho(rho), NR(NR), NA(NA), a0(a0),rmin(rmin),rmax(rmax),
     axisymmetric(axisymmetric), triaxial(triaxial), flip(flip), err(err){

    NA_phi = axisymmetric?1:NA;
    NA_theta = NA;

    if(LMAX1>0) LMAX = LMAX1;
    else{
        if(flip)LMAX = NA_theta*8.;
        else LMAX = NA_theta*4.;
    }
    if(MMAX1>0) MMAX = MMAX1;
    else MMAX = LMAX;
    if(axisymmetric) MMAX = 0;

    GLtheta = std::unique_ptr<GaussLegendreIntegrator>
            (new GaussLegendreIntegrator(2.*NA_theta-1));
    GLphi = std::unique_ptr<GaussLegendreIntegrator>
            (new GaussLegendreIntegrator(2.*NA_phi-1));

    fill_radial_grid(a0,rmin,rmax);

    rho_grid=std::vector<std::vector<VecDoub>>(2*NA_theta-1,std::vector<VecDoub>(2*NA_phi-1,VecDoub(NR,0.)));
    fill_density_grid();

    Phi_grid=std::vector<std::vector<VecDoub>>(LMAX+1,std::vector<VecDoub>(2.*LMAX+1,VecDoub(NR,0.)));
    dPhi_grid=Phi_grid;
    fillPhigrid();
}
ModelParameters::ModelParameters ()
{
    // init parameter values
	mf_NumSpecies = 2 ;
	mf_NumReacs = 4 ;

	mf_ReacRates = VecDoub ( mf_NumReacs , 0. ) ;

    mf_ReacRates[0] = 0.0 ; //mrna_prod
    mf_ReacRates[1] = 0.0 ; //mrna_degrad
    mf_ReacRates[2] = 0.0 ; //protein_prod
    mf_ReacRates[3] = 0.0 ; //protein_degrad
}
Ejemplo n.º 5
0
MultipoleExpansion::MultipoleExpansion(const std::string& inFile):err(0.){

    std::ifstream infile; infile.open(inFile);
    if(!infile.is_open())std::cerr<<"Can't open "<<inFile<<std::endl;

    infile >>NR>>NA>>LMAX>>MMAX>>a0>>rmin>>rmax>>axisymmetric>>triaxial>>flip;

    NA_phi = axisymmetric?1:NA;
    NA_theta = NA;

    GLtheta = std::unique_ptr<GaussLegendreIntegrator>
            (new GaussLegendreIntegrator(2.*NA_theta-1));

    GLphi = std::unique_ptr<GaussLegendreIntegrator>
            (new GaussLegendreIntegrator(2.*NA_phi-1));

    fill_radial_grid(a0,rmin,rmax);

    rho_grid=std::vector<std::vector<VecDoub>>(2.*NA_theta-1,std::vector<VecDoub>(2.*NA_phi-1,VecDoub(NR,0.)));
    for(unsigned int i=0;i<rho_grid.size();i++)
        for(unsigned int j=0;j<rho_grid[0].size();j++)
            for(unsigned int k=0;k<rho_grid[0][0].size();k++){
                infile>>rho_grid[i][j][k];
            }

    if(axisymmetric) MMAX = 0;
    Phi_grid=std::vector<std::vector<VecDoub>>(LMAX+1,std::vector<VecDoub>(2.*LMAX+1,VecDoub(NR,0.)));
    dPhi_grid=Phi_grid;
    for(unsigned int i=0;i<Phi_grid.size();i++)
        for(unsigned int j=0;j<Phi_grid[0].size();j++)
            for(unsigned int k=0;k<Phi_grid[0][0].size();k++){
                infile>>Phi_grid[i][j][k];
            }
    for(unsigned int i=0;i<dPhi_grid.size();i++)
        for(unsigned int j=0;j<dPhi_grid[0].size();j++)
            for(unsigned int k=0;k<dPhi_grid[0][0].size();k++){
                infile>>dPhi_grid[i][j][k];
            }
    infile.close();

}
Ejemplo n.º 6
0
Actions_AxisymmetricFudge_InterpTables::Actions_AxisymmetricFudge_InterpTables(Potential_JS *Pot, std::string name, bool tab, double Rm, double Rn,int NR, int NGRID,int NED,int NEL)
    :Pot(Pot),name(name)
    ,Rmin(Rm),Rmax(Rn),NR(NR),NGRID(NGRID),UV(new uv_orb(Pot,Rm,Rn,NED,NEL)){

    no_table=false;

    Rgrid = VecDoub(NR); Lzgrid = VecDoub(NR); Vmax = VecDoub(NR);
    Lcgrid = VecDoub(NR);
    E0grid = VecDoub(NR); Unigrid = VecDoub(NGRID+1);
    Iu0 = VecDoub(NR); Iv0 = VecDoub(NR);
    kappagrid = VecDoub(NR); nugrid = VecDoub(NR); Omegacgrid = VecDoub(NR);
    Jr_LzEIu=std::vector<std::vector<VecDoub>>(NR,std::vector<VecDoub>(NGRID,VecDoub(NGRID)));
    Iugrid=Jr_LzEIu; Jz_LzEIv=Jr_LzEIu; Ivgrid=Jr_LzEIu;
    Iumin=std::vector<VecDoub>(NR,VecDoub(NGRID)); Iumax=Iumin;
    Ivmin=std::vector<VecDoub>(NR,VecDoub(NGRID)); Ivmax=Ivmin;

    for(int i=0; i<=NGRID; i++)
        Unigrid[i]=((double)i/(double)(NGRID));//   standard grid
    for(int i=0; i<NR; i++)
        Rgrid[i]=Rmin+i*(Rmax-Rmin)/((double)(NR-1));

    if(tab) tab_acts();
    else get_acts();
}
Ejemplo n.º 7
0
void MiaMarkerStatistics::readKeyValues(MiaMarker* marker, A* inData)
{
    MiaPoint4D lastpt;
    VecDoub x = VecDoub( marker->getKeyPointNumber() ); //this data structure is specific from numerical recipes
    VecDoub y = VecDoub( marker->getKeyPointNumber() );
    double curr_dist = 0;

    marker->keyValueList.clear();
    if ( marker->getKeyPointNumber() > 0 )
    {
        lastpt = inputImage->convertPatientCoordinateToVoxel(marker->getKeyPointAt(0));

    }
    else
    {
        return;
    }
//     qDebug()<<"Before fitting";
    for (int i = 0; i < marker->getKeyPointNumber(); i++)
    {
        MiaPoint4D pt = marker->getKeyPointAt(i);
        pt = inputImage->convertPatientCoordinateToVoxel(pt);

        float value = inputImage->getValueAt(pt.pos);
        value = -value-1.0;
        if(value>0)
            value = 0;
        curr_dist = curr_dist + lastpt.distance(pt);
        x[i] = curr_dist;
        y[i] = value;
        lastpt = pt;
//        qDebug()<<x[i]<<y[i];
    }

    //robust regression from numerical recipes
    float last_a = 10.0, last_b = 0.0;
//    if(soomthingWindow>100)
//    {
//        MiaMarker3DPolygon* centerline = (MiaMarker3DPolygon*)marker;
//        if(centerline->bifurcationNodeList.size()<2)
//        {
//            qDebug()<<"Single Segment Robust fitting";
//            Fitmed f(x, y);
//            qDebug()<<f.b<<f.a;
//            if(f.b<0)
//            {
//                f.a = f.a + f.b * curr_dist/2.0;
//                f.b = 0;
//                qDebug()<<f.b<<f.a;
//            }

//            //modify the kewValueList with the values obtained from the regression
//            for (int i = 0; i < marker->getKeyPointNumber(); i++)
//            {
//                Point4D v;
//                v.pos[3] = f.a + f.b * x[i];
//                if(v.pos[3]>-1.0)
//                    v.pos[3] = -1.0;
//                marker->keyValueList.append(v);
//        //        qDebug()<<x[i]<<v.pos[3];
//            }
//        }
//        else
//        {
//            qDebug()<<"Multipele Segment Robust fitting";
//            for(int seg = 0; seg < centerline->bifurcationNodeList.size() -1; seg++)
//            {
//                int start = centerline->bifurcationNodeList.at(seg);
//                int end = centerline->bifurcationNodeList.at(seg+1);
//                VecDoub sx = VecDoub( end - start );
//                VecDoub sy = VecDoub( end - start );
//                for(int i = start; i <end ; i ++)
//                {
//                    sx[i-start] = x[i];
//                    sy[i-start] = y[i];
//                }
//                Fitmed f(sx, sy);
//                qDebug()<<f.b<<f.a;
//                if(f.b<0)
//                {
//                    f.a = f.a + f.b * x[(start+end)/2]/2.0;
//                    f.b = 0;
//                    qDebug()<<f.b<<f.a;
//                }

//                //modify the kewValueList with the values obtained from the regression
//                for(int i = start; i <end ; i ++)
//                {
//                    Point4D v;
//                    v.pos[3] = f.a + f.b * x[i];
//                    if(v.pos[3]>-1.0)
//                        v.pos[3] = -1.0;
//                    marker->keyValueList.append(v);
////                    qDebug()<<x[i]<<v.pos[3];
//                }
//                if(end == marker->getKeyPointNumber()-1)
//                {
//                    Point4D v;
//                    v.pos[3] = f.a + f.b * x[end];
//                    if(v.pos[3]>-1.0)
//                        v.pos[3] = -1.0;
//                    marker->keyValueList.append(v);

//                }
//            }
//            qDebug()<<marker->keyPointList.size();
//            qDebug()<<marker->keyValueList.size();

//        }
//        return;
//    }

    int local_n = soomthingWindow;
    for(int i = 0; i < marker->getKeyPointNumber(); i++)
    {
        int pre_n,next_n;
        float localmean = 0.0;
        pre_n = max(0,i-local_n);
        next_n = min(marker->getKeyPointNumber(), i+local_n);
        for(int j = pre_n; j < next_n; j++)
        {
            localmean += y[j];
        }
        localmean = localmean/(float)(next_n - pre_n);
        MiaPoint4D v;
        v.pos[3] = localmean - 0.5; //0.5 is a bias field if too large the cylinder will grow forever, if too small the cynlinder will disappear
                                    //apperantly using cubic of the distance function will help to stablize this behavior
        if(v.pos[3]>-1.0)
            v.pos[3] = -1.0;
        marker->keyValueList.append(v);
//        qDebug()<<y[i]<<v.pos[3];
    }

}