def write_to_file(self, fn):
with open(fn, '<STR_LIT:w>') as f:<EOL><INDENT>f.write('<STR_LIT>'.format(self.molecule.title))<EOL>f.write('<STR_LIT>'.format(self.subtitle))<EOL>def write_grid_line(n, v):<EOL><INDENT>f.write('<STR_LIT>' % (n, v[<NUM_LIT:0>], v[<NUM_LIT:1>], v[<NUM_LIT:2>]))<EOL><DEDENT>write_grid_line(self.molecule.size, self.origin)<EOL>write_grid_line(self.data.shape[<NUM_LIT:0>], self.axes[<NUM_LIT:0>])<EOL>write_grid_line(self.data.shape[<NUM_LIT:1>], self.axes[<NUM_LIT:1>])<EOL>write_grid_line(self.data.shape[<NUM_LIT:2>], self.axes[<NUM_LIT:2>])<EOL>def write_atom_line(n, nc, v):<EOL><INDENT>f.write('<STR_LIT>' % (n, nc, v[<NUM_LIT:0>], v[<NUM_LIT:1>], v[<NUM_LIT:2>]))<EOL><DEDENT>for i in range(self.molecule.size):<EOL><INDENT>write_atom_line(self.molecule.numbers[i], self.nuclear_charges[i],<EOL>self.molecule.coordinates[i])<EOL><DEDENT>for i0 in range(self.data.shape[<NUM_LIT:0>]):<EOL><INDENT>for i1 in range(self.data.shape[<NUM_LIT:1>]):<EOL><INDENT>col = <NUM_LIT:0><EOL>for i2 in range(self.data.shape[<NUM_LIT:2>]):<EOL><INDENT>value = self.data[i0, i1, i2]<EOL>if col % <NUM_LIT:6> == <NUM_LIT:5>:<EOL><INDENT>f.write('<STR_LIT>' % value)<EOL><DEDENT>else:<EOL><INDENT>f.write('<STR_LIT>' % value)<EOL><DEDENT>col += <NUM_LIT:1><EOL><DEDENT>if col % <NUM_LIT:6> != <NUM_LIT:5>:<EOL><INDENT>f.write('<STR_LIT:\n>')<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Write the cube to a file in the Gaussian cube format.