Thanks for the good questions.
a) for the filling you have two options: the main one is to use our quantum number (QN) conservation system, which works as you guessed: if you use site indices (calling the
siteinds function) with the conserve_qns=true, then when you prepare the initial state for DMRG, the number of particles in that initial state will remain unchanged by our DMRG code.
If you turn off or do not conserve particle number, then you would have to add a chemical potential term to your Hamiltonian or otherwise tune your Hamiltonian to get the density that you want.
b) for making custom measurements or other behaviors during a DMRG calculation, we have a very powerful system called the "Observer System" where you define a custom type and a function called
measure! for it that will be called throughout the DMRG code (if you pass your observer type to the
dmrg function). Then in your
measure! function you can put any code you want, such as measuring local observables, calling the
expect function to measure every site (I would do this only once per sweep, since it's a global measurement), write data to files, and anything else. Please let us know if you have any questions about how to use it.