From e1569a2973ac6c22419e921b00dfb0e1db119742 Mon Sep 17 00:00:00 2001 From: bpuchala Date: Wed, 28 Aug 2024 16:09:27 -0400 Subject: [PATCH] ClexulatorWriter dump files quietly, because they are listed in generated_files later; Add validation warnings --- casm/bset/clexwriter/_methods.py | 12 ++++---- .../cluster_functions/_cluster_functions.py | 30 +++++++++++++++++-- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/casm/bset/clexwriter/_methods.py b/casm/bset/clexwriter/_methods.py index 34c1385..3ef3d08 100644 --- a/casm/bset/clexwriter/_methods.py +++ b/casm/bset/clexwriter/_methods.py @@ -907,7 +907,7 @@ def write( path = self.bset_dir / "cluster_functions.json.gz" generated_files.append(path) - dump(builder.to_dict(), path, force=True, gz=True) + dump(builder.to_dict(), path, quiet=True, force=True, gz=True) if verbose: print("Building cluster functions DONE") @@ -971,19 +971,19 @@ def write( data = builder.basis_dict( clex_basis_specs=clex_basis_specs, coordinate_mode="frac" ) - dump(data, path, force=True) + dump(data, path, quiet=True, force=True) # write all template variables path = self.bset_dir / "variables.json.gz" generated_files.append(path) - dump(writer.variables(), path, force=True, gz=True) + dump(writer.variables(), path, quiet=True, force=True, gz=True) ## if local clexulators if phenomenal is not None: # write equivalents_info.json path = self.bset_dir / "equivalents_info.json" generated_files.append(path) - dump(builder.equivalents_info_dict(), path, force=True) + dump(builder.equivalents_info_dict(), path, quiet=True, force=True) # write each local clexulator self.local_src_path = [] @@ -1020,7 +1020,7 @@ def write( # write all template variables path = local_dir / "variables.json" generated_files.append(path) - dump(writer.variables(), path, force=True) + dump(writer.variables(), path, quiet=True, force=True) # write generated_files.json (includes itself) path = self.bset_dir / "generated_files.json" @@ -1034,5 +1034,5 @@ def write( data["local_src_path"] = [ str(p.relative_to(self.bset_dir)) for p in self.local_src_path ] - dump(data, path, force=True) + dump(data, path, quiet=True, force=True) return None diff --git a/casm/bset/cluster_functions/_cluster_functions.py b/casm/bset/cluster_functions/_cluster_functions.py index de69735..4a68948 100644 --- a/casm/bset/cluster_functions/_cluster_functions.py +++ b/casm/bset/cluster_functions/_cluster_functions.py @@ -676,6 +676,32 @@ class used is :class:`~casm.bset.cluster_functions.MakeVariableName`. only_discrete = len(global_dof) + len(local_continuous_dof) == 0 + # Validation + if len(local_discrete_dof) == 0: + if occ_site_basis_functions_specs is not None: + print( + "\n" + "****************************************************************\n" + "** Warning in ClusterFunctionsBuilder: **\n" + "** No local discrete DoF, but: **\n" + "** - occ_site_basis_functions_specs is not None **\n" + "** Will use occ_site_basis_functions_specs=None **\n" + "****************************************************************\n" + ) + occ_site_basis_functions_specs = None + if len(global_dof + local_continuous_dof) > 0: + if global_max_poly_order is None and len(orbit_branch_max_poly_order) == 0: + print( + "\n" + "****************************************************************\n" + "** Warning in ClusterFunctionsBuilder: **\n" + "** Continuous DoF included, but: **\n" + "** - global_max_poly_order is None, and **\n" + "** - len(orbit_branch_max_poly_order) == 0 **\n" + "** Did you forget to set global_max_poly_order?? **\n" + "****************************************************************\n" + ) + # Data self._prim = prim """libcasm.configuration.Prim: The Prim, with symmetry information""" @@ -931,12 +957,12 @@ class used is :class:`MakeVariableName`. Custom classes should have `i_func`-th function on the cluster given by `clusters[i_orbit][i_equiv]`. """ - n_functions = 0 + n_functions = 1 for orbit_basis_set in orbit_basis_sets: n_functions += len(orbit_basis_set[0]) self.n_functions = n_functions """int: The total number of symmetrically distinct cluster functions generated - for all clusters in all orbits.""" + for all clusters in all orbits plus one (for the constant term).""" self.clusters = orbit_clusters """list[list[libcasm.clusterography.Cluster]]: The clusters for which