arn-all / Kinetic_Monte_Carlo_Code

1 stars 0 forks source link

Allow C atoms positions to be given as a np.ndarray #3

Closed arn-all closed 4 years ago

arn-all commented 4 years ago

Write some function that transforms np.ndarray to KMC-readable json file.

arn-all commented 4 years ago
def save_pos_to_json(positions, filename, comment=""):
   """Saves a np.ndarray (positions) to the specified location in write mode.
   """
    pos_dict = {    
            "comment":comment,  
            "pd_pos": positions.tolist()  
        }                  

    with open(filename, 'w') as f: 
        json.dump(pos_dict, f)