using PorousMaterials # use major_refactor branch.
using Base #这是个标准模块
using DataFrames
using PyPlot
using NPZ
using CSV
using LightGraphs
using LinearAlgebra
using Logging
using Printf
using DelimitedFiles
using ProgressMeter
using PyCall
push!(LOAD_PATH, pwd()) # to see Bonds.jl
using Bonds
using Statistics
# global_logger(Logging.SimpleLogger(stdout, Logging.Info)) # to print @debug put Logging.Debug
global_logger(Logging.SimpleLogger(stdout, Logging.Debug)) # to print @debug put Logging.Debug
┌ Info: Precompiling Bonds [top-level]
└ @ Base loading.jl:1273
WARNING: Method definition dot(Any, Any, Any) in module Compat at C:\Users\zzh666\.julia\packages\Compat\LtJN6\src\Compat.jl:172 overwritten in module Optim at C:\Users\zzh666\.julia\packages\Optim\cJRng\src\multivariate\precon.jl:24.
** incremental compilation may be fatally broken for this module **
ERROR: LoadError: UndefVarError: Crystal not defined
Stacktrace:
[1] top-level scope at c:\Users\zzh666\Desktop\任务\任务13-3\mpn_charges-master\build_graphs\Bonds.jl:36
[2] include at .\boot.jl:328 [inlined]
[3] include_relative(::Module, ::String) at .\loading.jl:1105
[4] include(::Module, ::String) at .\Base.jl:31
[5] top-level scope at none:2
[6] eval at .\boot.jl:330 [inlined]
[7] eval(::Expr) at .\client.jl:425
[8] top-level scope at .\none:3
in expression starting at c:\Users\zzh666\Desktop\任务\任务13-3\mpn_charges-master\build_graphs\Bonds.jl:36
Failed to precompile Bonds [top-level] to C:\Users\zzh666\.julia\compiled\v1.3\Bonds.ji.
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1283
[3] _require(::Base.PkgId) at .\loading.jl:1024
[4] require(::Base.PkgId) at .\loading.jl:922
[5] require(::Module, ::Symbol) at .\loading.jl:917
[6] top-level scope at In[9]:15
还有个报错
Failed to precompile Bonds [top-level] to C:\Users\zzh666.julia\compiled\v1.3\Bonds.ji.
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1283
[3] _require(::Base.PkgId) at .\loading.jl:1024
[4] require(::Base.PkgId) at .\loading.jl:922
[5] require(::Module, ::Symbol) at .\loading.jl:917
[6] top-level scope at In[9]:15
@info "making edge list zero-based indexed for Python"
keep_xtal = [true for i = 1:length(xtalnames)]
@showprogress for (i_xtal, xtalname) in enumerate(xtalnames)
crystal = Crystal(xtalname * ".cif", include_zero_charges=true;check_overlap=false)
@assert ! all(crystal.charges.q .== 0)
try
bonds!(crystal, true)
catch e
if isa(e, PyCall.PyError)
remove_bonds!(crystal) # some of the bonds were probz formed
println("Voronoi problems with " * crystal.name)
infer_bonds!(crystal, true) # infer bonds with old distance-based version
else
print("!!!", crystal.name); throw(e)
end
end
@assert nv(crystal.bonds) == crystal.atoms.n
if ! PorousMaterials.bond_sanity_check(crystal)
keep_xtal[i_xtal] = false
@warn "throwing out " crystal.name
continue
end
###
# node features
# one-hot encoding. each row is an atom.
###
x_ν = zeros(Int, crystal.atoms.n, length(ATOMS))
for (i, atom) in enumerate(crystal.atoms.species)
x_ν[i, ATOM_TO_INT[atom]] = 1
end
@assert sum(x_ν) == crystal.atoms.n
npzwrite(joinpath("graphs1", xtalname * "_node_features.npy"), x_ν)
###
# node labels (the charges)
###
y_ν = deepcopy(crystal.charges.q)
npzwrite(joinpath("graphs1", xtalname * "_node_labels.npy"), y_ν)
@assert length(y_ν) == size(x_ν)[1]
###
# edges
# (a list and their feature = distance btwn atoms)
###
edge_file = open(joinpath("graphs1", xtalname * ".edge_info"), "w")
@printf(edge_file, "src,dst,r\n")
for ed in edges(crystal.bonds)
i = src(ed) # source
j = dst(ed) # destination
r = distance(crystal.atoms, crystal.box, i, j, true)
@printf(edge_file, "%d,%d,%f\n", i - 1, j - 1, r)
end
close(edge_file)
end
writedlm(open("list_of_crystals.txt", "w"), xtalnames[keep_xtal])
WARNING: both Graphs and LightGraphs export "edges"; uses of it in module Main must be qualified
WARNING: both Graphs and LightGraphs export "nv"; uses of it in module Main must be qualified
WARNING: both Graphs and LightGraphs export "add_edge!"; uses of it in module Bonds must be qualified
WARNING: both Graphs and LightGraphs export "ne"; uses of it in module Bonds must be qualified
WARNING: both Graphs and LightGraphs export "src"; uses of it in module Main must be qualified
WARNING: both Graphs and LightGraphs export "dst"; uses of it in module Main must be qualified
!!!SEHSUU_clean.cifERROR: UndefVarError: ne not defined
Stacktrace:
[1] macro expansion
@ .\REPL[97]:12 [inlined]
[2] top-level scope
@ C:\Users\zzh666\.julia\packages\ProgressMeter\sN2xr\src\ProgressMeter.jl:938
caused by: UndefVarError: ne not defined
Stacktrace:
[1] bonds!(crystal::Crystal, apply_pbc::Bool)
@ Bonds C:\Users\zzh666\Desktop\renwu\renwu13-3\111\mpn_charges-master\build_graphs\Bonds.jl:150
[2] macro expansion
@ .\REPL[97]:5 [inlined]
[3] top-level scope
@ C:\Users\zzh666\.julia\packages\ProgressMeter\sN2xr\src\ProgressMeter.jl:938
刚跑得,似乎Graphs and LightGraphs有这个包
WARNING: both Graphs and LightGraphs export “ne”; uses of it in module Bonds must be qualified