Distribution Functions and Thermodynamical Properties of KD2PO4 and ND4D2PO4 Type Crystals