![]() ![]() ![]() ![]() What you are describing, is the conversion from XYZ format to ZMAT format. Here's an example script inspired by rsdel's answer which uses ASE: import ase.ioĪtom = ase.io.read(io.StringIO(xyz_file), format = 'xyz')Įasiest free tool to do this (no download necessary): The ASE library has an atom object with built-in get_angle, get_dihedral and get_distance methods that do just that. From the xyz parameters, I need to find the distance between atoms, angle and dihedral between atoms. But if your constraints do not consider the distribution, this could do as well (and this will give you a matrix from a single run).I want to make a python script that will load an xyz file. Note that as pointed out, this will have a different distribution as the rejection method. For practical reasons I padded the matrix with a zero line and column at the beginning to avoid indexing problems with k1-1 and k2-1. It's a bit tricky because for each element you check the row-sum and column-sum until that point, and use the larger of the two for generating a new element (in order to stay below a sum of 1 in both directions). Matrix = zeros(n+1) %dummy line in first row/column For this you always generate a new element between 0 and the remainder until 1: n = 3 So another, but more tedious approach is to generate each element such that the sum can only be 1 in each direction. The rejection method will surely give you a uniform solution, but it might take a long time to generate a good matrix, especially if your matrix is large. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |