Skip to content

Commit

Permalink
chore: pw.x schema improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
k0stik committed Sep 11, 2023
1 parent 0fbbb1e commit e5ce061
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 30 deletions.
12 changes: 6 additions & 6 deletions example/3pse/file/applications/espresso/7.2/pw.x.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
],
"Hubbard_occ": [
[
1.1,
0.00,
1,
1,
0.00
],
[
0.02,
0.02,
1,
2,
0.02
]
]
Expand All @@ -49,12 +49,12 @@
"ATOMIC_SPECIES": {
"values": [
{
"x": "Cs",
"X": "Cs",
"Mass_X": 132.90543,
"PseudoPot_X": "Cs.upf"
},
{
"x": "Cl",
"X": "Cl",
"Mass_X": 35.4527,
"PseudoPot_X": "Cl.upf"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"properties": {
"X": {
"type": "string",
"description": "label of the atom as specified in ATOMIC_SPECIE"
"description": "label of the atom as specified in ATOMIC_SPECIES"
},
"x": {
"type": "number",
Expand All @@ -40,24 +40,18 @@
"description": "atomic positions"
},
"if_pos(1)": {
"type": "number",
"$ref": "../../../../../../core/primitive/integer_one_or_zero.json",
"default": 1,
"minimum": 0,
"maximum": 1,
"description": "component i of the force for this atom is multiplied by if_pos(i), which must be either 0 or 1. Used to keep selected atoms and/or selected components fixed in MD dynamics or structural optimization run."
},
"if_pos(2)": {
"type": "number",
"$ref": "../../../../../../core/primitive/integer_one_or_zero.json",
"default": 1,
"minimum": 0,
"maximum": 1,
"description": "component i of the force for this atom is multiplied by if_pos(i), which must be either 0 or 1. Used to keep selected atoms and/or selected components fixed in MD dynamics or structural optimization run."
},
"if_pos(3)": {
"type": "number",
"$ref": "../../../../../../core/primitive/integer_one_or_zero.json",
"default": 1,
"minimum": 0,
"maximum": 1,
"description": "component i of the force for this atom is multiplied by if_pos(i), which must be either 0 or 1. Used to keep selected atoms and/or selected components fixed in MD dynamics or structural optimization run."
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "object",
"additionalProperties": false,
"properties": {
"x": {
"X": {
"type": "string",
"description": "label of the atom. Acceptable syntax: chemical symbol X (1 or 2 characters, case-insensitive) or chemical symbol plus a number or a letter, as in \"Xn\" (e.g. Fe1) or \"X_*\" or \"X-*\" (e.g. C1, C_h; max total length cannot exceed 3 characters)"
},
Expand Down
6 changes: 4 additions & 2 deletions schema/3pse/file/applications/espresso/7.2/pw.x/control.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@
},
"gate": {
"type": "boolean",
"default": false
"default": false,
"description": "In the case of charged cells (tot_charge .ne. 0) setting gate = .TRUE. represents the counter charge (i.e. -tot_charge) not by a homogeneous background charge but with a charged plate, which is placed at zgate (see below). Details of the gate potential can be found in T. Brumme, M. Calandra, F. Mauri; PRB 89, 245406 (2014). Note, that in systems which are not symmetric with respect to the plate, one needs to enable the dipole correction! (dipfield=.true.). Currently, symmetry can be used with gate=.true. but carefully check that no symmetry is included which maps z to -z even if in principle one could still use them for symmetric systems (i.e. no dipole correction). For nosym=.false. verbosity is set to 'high'. Note: this option was called \"monopole\" in v6.0 and 6.1 of pw.x"
},
"twochem": {
"type": "boolean",
Expand All @@ -173,7 +174,8 @@
},
"trism": {
"type": "boolean",
"default": false
"default": false,
"description": "If .TRUE. perform a 3D-RISM-SCF calculation [for details see H.Sato et al., JCP 112, 9463 (2000), doi:10.1063/1.481564]. The solvent's distributions are calculated by 3D-RISM, though solute is treated as SCF. The charge density and the atomic positions are optimized, simultaneously with the solvents. To perform the calculation, you must set a namelist RISM and a card SOLVENTS. If assume_isolated = 'esm' and esm_bc = 'bc1', Laue-RISM is calculated instead of 3D-RISM and coupled with ESM method (i.e. ESM-RISM). [for details see S.Nishihara and M.Otani, PRB 96, 115429 (2017)]. The default of mixing_beta is 0.2 for both 3D-RISM and Laue-RISM. For structural relaxation with BFGS, ignore_wolfe is always .TRUE. ."
}
}
}
23 changes: 17 additions & 6 deletions schema/3pse/file/applications/espresso/7.2/pw.x/system.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
"type": "array",
"items": {
"type": "number",
"default": 0
"default": 0,
"minimum": -1,
"maximum": 1
}
},
"ecutwfc": {
Expand Down Expand Up @@ -304,11 +306,20 @@
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3
"items": [
{
"type": "integer",
"minimum": 1
},
{
"type": "integer",
"minimum": 1,
"maximum": 3
},
{
"type": "number"
}
]
}
},
"Hubbard_alpha": {
Expand Down
8 changes: 8 additions & 0 deletions schema/core/primitive/integer_one_or_zero.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$id": "core/primitive/integer-one-or-zero",
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "integer one or zero",
"type": "number",
"minimum": 0,
"maximum": 1
}
8 changes: 7 additions & 1 deletion src/js/esse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export class ESSE {
*/
validate = (example, schema) => {
const ajv = new Ajv({ allErrors: true });
return ajv.validate(schema, example);
const isValid = ajv.validate(schema, example);

if (!isValid) {
console.error(ajv.errors);
}

return isValid;
};

buildGlobalSchema() {
Expand Down
5 changes: 1 addition & 4 deletions src/js/scripts/createEnumsFromYaml.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@ walkDir(SCHEMA_DIR, (filePath) => {
const obj = yaml.load(fileContents);
const enumObj = lodash.mapValues(obj, (value) => ({ enum: value }));

fs.writeFileSync(
`${path.join(dirname, outFilename)}`,
`${JSON.stringify(enumObj, null, 4)}\n`,
);
fs.writeFileSync(`${path.join(dirname, outFilename)}`, `${JSON.stringify(enumObj, null, 4)}\n`);
});

0 comments on commit e5ce061

Please sign in to comment.