Development of a phase field method for modeling brittle and ductile fracture