Skip to content

Commit

Permalink
Adding most bound BH ID and position to output
Browse files Browse the repository at this point in the history
Added the position and ID of the BH that is closest to the most bound dark matter particle.
This was tested in COLIBRE and works well.
  • Loading branch information
cdplagos committed Dec 21, 2021
1 parent 343f294 commit dc6d330
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/allvars.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,9 @@ void PropDataHeader::declare_all_datasets(const Options &opt)
#ifdef BHON
declare_dataset<unsigned long>("n_bh");
declare_dataset("Mass_bh", MASS);
//save ID most bound BH and its position
declare_dataset<long>("ID_mbp_bh");
declare_XYZ_datasets("cmbp_bh", LENGTH);
#endif // BHON

#ifdef HIGHRES
Expand Down
5 changes: 5 additions & 0 deletions src/allvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,10 @@ struct PropData
///mean accretion rate, metallicty
Double_t acc_bh, acc_bh_mostmassive;

///ID of most bound BH and its position
Int_t ibound_bh = 0;
Coordinate gposmbp_bh;

///\name blackhole aperture/radial profiles
//@{
vector<int> aperture_npart_bh;
Expand Down Expand Up @@ -2478,6 +2482,7 @@ struct PropData
#endif
#ifdef BHON
M_bh*=opt.h;
gposmbp_bh*=opt.h/opt.a;
#endif
#ifdef HIGHRES
M_interloper*=opt.h;
Expand Down
9 changes: 9 additions & 0 deletions src/io.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,15 @@ void WriteProperties(Options &opt, const Int_t ngroups, PropData *pdata){

for (Int_t i=0;i<ngroups;i++) ((Double_t*)data)[i]=pdata[i+1].M_bh;
Fhdf.write_dataset(opt, head.headerdatainfo[itemp],ng,data,head.hdfpredtypeinfo[itemp]);itemp++;

for (Int_t i=0;i<ngroups;i++) ((long long*)data)[i]=pdata[i+1].ibound_bh;
Fhdf.write_dataset(opt, head.headerdatainfo[itemp],ng,data,head.hdfpredtypeinfo[itemp]);itemp++;

for (int k=0;k<3;k++){
for (Int_t i=0;i<ngroups;i++) ((Double_t*)data)[i]=pdata[i+1].gposmbp_bh[k];
Fhdf.write_dataset(opt, head.headerdatainfo[itemp],ng,data,head.hdfpredtypeinfo[itemp]);itemp++;
}

#endif
#ifdef HIGHRES
for (Int_t i=0;i<ngroups;i++) ((unsigned long*)data)[i]=pdata[i+1].n_interloper;
Expand Down
16 changes: 16 additions & 0 deletions src/substructureproperties.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,14 @@ private(EncMassSF,EncMassNSF,Krot_sf,Krot_nsf,Ekin_sf,Ekin_nsf)
mval = opt.MassValue;
#endif
pdata[i].M_bh+=mval;

//save particle information if the most bound id has not been assigned.
//note that this works because particles has been previously ordered by distance to defined centre.
if(pdata[i].ibound_bh == 0){
pdata[i].ibound_bh = Pval->GetPID();
for (k=0;k<3;k++) pdata[i].gposmbp_bh[k] = Pval->GetPosition(k) + pdata[i].gposmbp[k];
}

}
}
#endif
Expand Down Expand Up @@ -2073,6 +2081,14 @@ private(j,Pval,x,y,z,vx,vy,vz,jval,jzval,zdist,Rdist)
mval = opt.MassValue;
#endif
pdata[i].M_bh+=mval;

//save particle information if the most bound id has not been assigned.
//note that this works because particles has been previously ordered by distance to defined centre.
if(pdata[i].ibound_bh == 0){
pdata[i].ibound_bh = Pval->GetPID();
for (k=0;k<3;k++) pdata[i].gposmbp_bh[k] = Pval->GetPosition(k) + pdata[i].gposmbp[k];
}

}
}
#endif
Expand Down

1 comment on commit dc6d330

@MatthieuSchaller
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jchelly this should be what you need for the lightcones. I can test it if you want.

Please sign in to comment.