# function read_POSCAR(filename, name = "POSCAR")
#     open(filename, "r") do f
#         readline(f) #comment line
#         lattice_constant = parse(Float64, strip(readline(f))) * 1angstrom
#         cell = Mat3(vcat([map(x -> parse(Float64, x), split.(readline(f))) for i in 1:3]...)) *
#                lattice_constant
#         atom_symbols = Symbol.(split(readline(f)))
#         natoms = parse.(Int, split(readline(f)))
#         t = lowercase(readline(f)[1])

#         cartesian = t == 'c' || t == 'k'
#         atoms = Atom[]
#         for (atsym, nats) in zip(atom_symbols, natoms)
#             for i in 1:nats
#                 if cartesian
#                     pos_cart = parse(Point3{Float64}, readline(f)) * 1angstrom
#                     pos_cryst = inv(cell) * pos_cart
#                     push!(atoms, Atom(atsym, atsym, pos_cart, pos_cryst))
#                 else
#                     pos_cryst = parse(Point3{Float64}, readline(f))
#                     pos_cart = cell * pos_cryst
#                     push!(atoms, Atom(atsym, atsym, pos_cart, pos_cryst))
#                 end
#             end
#         end
#         return Structure(cell, atoms)
#     end
# end

# function write_POSCAR(filename, structure)
#     open(filename, "w") do f
#         write(f, "Generated by DFControl\n")
#         write(f, "1.\n")
#         for i in 1:3
#             map(x -> write(f, "$(ustrip(uconvert(angstrom, x))) "), structure.cell[:, i])
#             write(f, "\n")
#         end
#         unique_els = unique(element.(structure.atoms))
#         for e in unique_els
#             write(f, "$(e.symbol) ")
#         end
#         write(f, "\n")

#         natoms = map(x -> count(y -> element(y) == x, structure.atoms), unique_els)
#         map(x -> write(f, "$x "), natoms)
#         write(f, "\n")
#         write(f, "Direct\n")
#         for el in unique_els
#             for a in structure.atoms el)
#                 map(x -> write(f, "$x "), a.position_cryst)
#                 write(f, "\n")
#             end
#         end
#     end
# end
