#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
该代码主要用来生成球形的shape.dat,用于ddscat的计算
"""
header_template = """ >core_shell.py: NBX, NBY, NBZ= {} {} {}
{:>7} = NAT
1.0000 0.0000 0.0000 = A_1 vector
0.0000 1.0000 0.0000 = A_2 vector
1.000000 1.000000 1.000000 = lattice spacings (d_x,d_y,d_z)/d
0.0 0.0 0.0
JA IX IY IZ ICOMP(x,y,z)
"""
data = list()
index = 1
radius = 20
for x in range(-1*radius, radius+1):
for y in range(-1*radius, radius+1):
for z in range(-1*radius, radius+1):
if x**2 + y**2 + z**2 <= radius**2:
data.append('{:>7}{:>4}{:>4}{:>4} 1 1 1\n'.format(index, x, y, z))
index = index + 1
with open('shape.dat', 'w', encoding="utf-8") as f:
f.write(header_template.format(radius*2, radius*2, radius*2, index-1))
f.write(''.join(data))