update D with ipopt, fixed some bugs