


Since (to be discussed below) the name of the fragment type as it is defined under atoms (explicitly with the adf.f=option, or implicitly as the name of the atom type) might also directly indicate the fragment file, the specification of fragment types is in principle case-sensitive. Exceptions are the names of files and directories. Note: Input items are generally case insensitive. (The numbering |n is then added automatically by the program, by counting the number of times that this single-atom fragment type occurs in the list of atoms). When adf.f=fragment is omitted altogether, the fragment type is taken to be the atom type that was specified earlier on the same line. The numbering suffix |n is not required if there is only one fragment of that type. The integer n, after the pipe |, counts the individual fragments of that type. The fragment name must be of the form fragtype|n, where fragtype is the name of one of the types of fragments in the molecule. Specifies that the atom belongs to a particular fragment. Else, you will have to find a workaround for every problem you encounter because you do not access/set indices by the standard way. In general, you must set the interface of your new class the same as ndarray to have no problem. Written as such, it cannot be generalized for more dimension.(Note: it would be interesting to do actually) It might be feasible but needs additional work. You can inherit from or composed it from the ndarray. One way to get around this would be to implement a class CartesianMatrix - for example - and put our functions in its method.Plus, you lose a part of the broadcasting from numpy. As such, it might not work well with libraries. The interface of accessing/setting your values is not standard.Well, we can say we have your solution, but this approach brings a bunch of problems: Return map_to_i(i_origin, y), map_to_j(j_origin, x) If you want, we can even make a function to have a tuple of (i, j): def map_to_matrix_indices(i_origin: int, j_origin: int, x: int, y: int) -> tuple: So, we can write the two short functions: def map_to_i(i_origin: int, y: int) -> int:ĭef map_to_j(j_origin: int, x: int) -> int: If you take a pencil and a paper I think we can agree that: i = i_origin - y We wil use i_origin as an offset for the lines' indices - vertical - so for y and j_origin for x We can do i_origin = matrix.shape // 2 and j_origin = matrix.shape // 2. Those variables are the i and j for the cartesian origin of the plane (0, 0). The last introduced variable are i_origin and j_origin. For example from (2, 1) you want the top left value with matrix indices (0, 4). What you want is a mapping from (x, y) to (i, j). Also we will note x and y as our cartesian indices. We will denote the indices of this matrix as i and j. The matrix which is meant to represent the cartesian plane between x_values = np.arange(-2, 2+1), y_values = np.arrange(-1, 1+1): matrix = np.array[ The solutionīefore, I will introduce some variables. I think this the standard and straightforward way, therefore the privilegied way to do that.
#Cartesian to zmatrix how to#
Here is a simple example how to perform computation on a 2D cartesian plane with meshgrid. I would advise to look at meshgrid for this. Although I will explain why the approach is very clunky and will lead to problem later in your experiments. I will provide a solution to your problem.
