Modeling brittle and ductile behavior of solids from first-principles calculations