3. 用户输入规则配置文件¶
该文件为一个Python配置文件,会随程序一起默认安装在 /<安装目录>/ngm/
下, 用户无需修改。
文件中定义了一个Python dict INPUT_SCHEMA
,CRANE在启动计算之前会基于该文件定义的输入内容规则,调用
python-jsonschema 库,来排查 用户输入文件 中的输入内容错误。
文件详细内容如下:
POINT = {
"type": "object",
"properties": {
"x": {"type": "number"},
"y": {"type": "number"}
},
"required": ["x", "y"]
}
TEMPERATURE = {
"type": "number",
"minimum": 0.0,
"maximum": 2000
}
MACRO_XS = {
"type": "array",
"items": {
"type": "number",
"minimum": 0.0,
"maximum": 1e+6,
},
"minItems": 1
}
LENGTH = {
"type": "number",
"inclusiveMinimum": 0.0,
"maximum": 1000.0,
}
CELL_MAP = {
"type": "array",
"items": {"type": "string"},
"minItems": 1
}
BORON = {
"type": "number",
"minimum": 0.0,
"maximum": 4000.0
}
PRIMITIVES = {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"enum": ["CIRCLE", "POLYGON"]
},
"center": POINT,
"radius": {
"type": "number",
"exclusiveMinimum": 0.0
},
"vertexes": {
"type": "array",
"items": POINT,
"minItems": 3,
"error_msg": "Polygon need at least 3 vertexes",
},
},
"required": ["type"],
"oneOf": [
{"required": ["type", "radius"]},
{"required": ["type", "vertexes"]},
],
"error_msg": "primitive defination require either 'radius' and 'center'(if needed) "
"when 'type' is CIRCLE or 'vertexes' when 'type' is POLYGON.",
},
"minItems": 1
}
REGIONS = {
"type": "array",
"items": {
"type": "object",
"properties": {
"material": {"type": "string"},
"space": {"type": "string"},
"tag": {"type": "string"}
},
"required": ["material", "space"]
},
"minItems": 1
}
MATERIAL_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"sigma_tr": MACRO_XS,
"sigma_f": MACRO_XS,
"nu_sigma_f": MACRO_XS,
"kappa_sigma_f": MACRO_XS,
"sigma_s": MACRO_XS,
"chi": {
"type": "array",
"items": {
"type": "number",
"minimum": 0.0,
"maximum": 1.0,
},
"minItems": 1
},
"elements": {
"type": "array",
"items": {"type": ["string", "integer"]},
"minItems": 1,
"uniqueItems": True
},
"density": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 22.5
},
# "temperature": {
# "type": "number",
# "minimum": 0.0,
# "maximum": 2000
# },
"weight_percents": {
"type": "array",
"items": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"minItems": 1
},
"volume_percents": {
"type": "array",
"items": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"minItems": 1
},
"number_densities": {
"type": "array",
"items": {
"type": "number",
"exclusiveMinimum": 0.0
},
"minItems": 1
},
"number_density_percents": {
"type": "array",
"items": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"minItems": 1
},
"atom_ratio": {
"type": "array",
"items": {
"type": "number",
"exclusiveMinimum": 0.0
},
"minItems": 1
},
},
"required": ["name"],
"oneOf": [
{"required": ["name", "sigma_tr", "sigma_f", "nu_sigma_f", "kappa_sigma_f", "sigma_s", "chi"]},
{"required": ["name", "elements", "atom_ratio"]},
{"required": ["name", "elements", "number_density_percents"]},
{"required": ["name", "elements", "number_densities"]},
{"required": ["name", "elements", "weight_percents", "density"]},
{"required": ["name", "elements", "volume_percents"]},
],
"error_msg": "material defination require one of these properties: 1).macro cross sections such as 'sigma_tr', "
"nu_sigma_f'... etc.; 2).'elements' and 'number_densities'; 3).'elements', 'weight_percents' and 'density', "
"see http://192.168.1.218:9091/io_formats/input.html#material",
}
STRUCTURE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"meshing": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["SECTORS", "RECTANGLES"]
},
"center": POINT,
"num_azimuths": {
"type": "integer",
"enum": [4, 6, 8, 12, 16],
},
"radii": {
"type": "array",
"items": LENGTH,
},
"num_divisions_x": {
"type": "integer",
"minimum": 1
},
"num_divisions_y": {
"type": "integer",
"minimum": 1
},
"xmin": LENGTH,
"xmax": LENGTH,
"ymin": LENGTH,
"ymax": LENGTH,
},
"required": ["type"],
"oneOf": [
{"required": ["type", "num_azimuths"]},
{"required": ["type", "num_divisions_x", "num_divisions_y", "xmin", "xmax", "ymin", "ymax"]},
],
"error_msg": "meshing defination require either 'num_azimuths', 'radii'(if needed) when 'type' is SECTOR or "
"'num_divisions_x', 'num_divisions_y', 'xmin', 'xmax', 'ymin' and 'ymax' when 'type' is RECTANGLE",
},
"primitives": PRIMITIVES,
"regions": REGIONS,
},
"required": ["name", "primitives", "regions"]
}
STRUCTURE_LOCATION = {
"type": "array",
"items": {
"type": "object",
"properties": {
"structure": {"type": "string"},
"location": POINT
},
"required": ["structure", "location"]
},
"minItems": 1,
}
LATTICE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"cell_map": CELL_MAP,
"structure_location": STRUCTURE_LOCATION,
"rectangle_meshing_density": {
"type": "number",
"minimum": 0.1,
"maximum": 1.0,
}
},
"required": ["name"],
"anyOf": [
{"required": ["name", "cell_map"]},
{"required": ["name", "structure_location"]},
],
"error_msg": "lattice defination require at least one of 'cell_map' and 'structure_location'"
}
GRID_SLICE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"grid_map": CELL_MAP,
"structure_location": STRUCTURE_LOCATION,
},
"required": ["name"],
"anyOf": [
{"required": ["name", "grid_map"]},
{"required": ["name", "structure_location"]},
],
"error_msg": "grid defination require at least one of 'grid_map' and 'structure_location'"
}
BAFFLE_SLICE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"regions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"thickness": LENGTH,
"material": {"type": "string"},
},
"required": ["thickness", "material"]
},
"minItems": 1
},
},
"required": ["name", "regions"]
}
AXIAL = {
"type": "array",
"items": {
"type": "object",
"properties": {
"slice": {"type": "string"},
"height": LENGTH
},
"required": ["slice", "height"]
},
"minItems": 1
}
GRIDS = {
"type": "array",
"items": {
"type": "object",
"properties": {
"slice": {"type": "string"},
"height": LENGTH,
"position": LENGTH
},
"required": ["slice", "height", "position"]
},
"minItems": 1
}
ASSEMBLY_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"axial": AXIAL,
"grids": GRIDS,
},
"required": ["name", "axial"]
}
INSERTED_ROD_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"axial": AXIAL,
},
"required": ["name", "axial"]
}
INSERTED_ROD_ASSEMBLY_BUNDLE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"inserting_map": CELL_MAP,
},
"required": ["name", "inserting_map"]
}
INSERTED_ROD_ANYWHERE_BUNDLE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"inserting_map": CELL_MAP,
"locations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"inserted_rod": {"type": "string"},
"location": POINT
},
"required": ["inserted_rod", "location"]
},
"minItems": 1
},
},
"required": ["name"],
"oneOf": [
{"required": ["name", "inserting_map"]},
{"required": ["name", "locations"]},
],
"error_msg": "control_rod_bundle defination require either 'inserting_map' or 'locations'"
}
CONTROL_ROD_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"max_num_steps": {
"type": "integer",
"minimum": 1,
},
"step_size": LENGTH,
"fully_withdrawn_height": LENGTH,
"banks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"bundle": {"type": "string"},
"position": {
"type": "integer",
"minimum": 0,
}
},
"required": ["name", "bundle", "position"]
},
"minItems": 1
},
"location_map": CELL_MAP,
"locations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"bank": {"type": "string"},
"location": POINT
},
"required": ["bank", "location"]
},
"minItems": 1
},
},
"required": ["max_num_steps", "step_size", "fully_withdrawn_height", "banks"],
"oneOf": [
{"required": ["max_num_steps", "step_size", "fully_withdrawn_height", "banks", "location_map"]},
{"required": ["max_num_steps", "step_size", "fully_withdrawn_height", "banks", "locations"]},
],
"error_msg": "control_rod defination require either 'location_map' or 'locations'"
}
DETECTOR_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"reaction_id": {
"type": "integer",
},
"axial": {
"type": "array",
"items": {
"type": "object",
"properties": {
"height": LENGTH,
"position": LENGTH,
},
"required": ["height", "position"]
},
"minItems": 1
},
"radial": {
"type": "array",
"items": {"type": "string"},
},
},
"required": ["axial", "radial"],
}
CORE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"type": {
"type": "string",
"enum": ["SQUARE", "HEXAGON"]
},
"symmetry": {
"type": "integer",
"enum": [1, 3, 4, 6, 8, 12, -3, -4, -6, -8, -12]
},
"periodic": {"type": "boolean"},
"assembly_rotated": {"type": "boolean"},
"assembly_pitch": LENGTH,
"cell_pitch": LENGTH,
"plane_max_thickness": LENGTH,
"assembly_column_index": {
"type": "array",
"items": {"type": "string"},
"minItems": 1
},
"assembly_row_index": {
"type": "array",
"items": {"type": "string"},
"minItems": 1
},
"current_cycle": {
"type": "integer",
"minimum": 1,
"maximum": 100,
},
"previous_cycles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"restart_file": {"type": "string"},
"shutdown_cooling_days": {
"type": "integer",
"minimum": 0,
}
},
"required": ["restart_file", "shutdown_cooling_days"],
},
"minItems": 1
},
"num_assembly_layers_reflector": {
"type": "integer",
"minimum": 1,
"maximum": 20,
},
"assembly_map": {
"type": "array",
"items": {"type": "string"},
"minItems": 1
},
"control_rod_map": {
"type": "array",
"items": {"type": "string"},
},
"control_rod_position": {
"type": "array",
"items": LENGTH,
},
"burnable_absorber_map": {
"type": "array",
"items": {"type": "string"},
},
"burnable_absorber_position": {
"type": "array",
"items": LENGTH,
},
"baffle": AXIAL,
"reflector": AXIAL,
"control_rod": CONTROL_ROD_SCHEMA,
"detector": DETECTOR_SCHEMA,
"mesh_type": {
"type": "string",
"enum": ["SECTORS"]
},
"rectangle_meshing_density": {
"type": "number",
"minimum": 0.1,
"maximum": 1.0,
},
"outer_albedo": {
"type": "number",
"minimum": 0.0,
"maximum": 1.0,
},
"top_boundary_condition": {
"type": "string",
"enum": ["REFLECTIVE", "VACUUM"],
},
"bottom_boundary_condition": {
"type": "string",
"enum": ["REFLECTIVE", "VACUUM"],
},
},
"required": ["name", "type", "symmetry", "cell_pitch", "assembly_pitch", "assembly_map"]
}
SETTINGS_SCHEMA = {
"type": "object",
"properties": {
"power_iteration": {
"type": "object",
"properties": {
"fission_converge_criterion": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"keff_converge_criterion": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"max_num_outer_iterations": {
"type": "integer",
"minimum": 1,
"maximum": 9999
},
}
},
"moc_2d": {
"type": "object",
"properties": {
"distribution_converge_criterion": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"keff_converge_criterion": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"num_inner_iterations": {
"type": "integer",
"minimum": 1,
"maximum": 100
},
"max_num_iterations": {
"type": "integer",
"minimum": 1,
"maximum": 9999
},
"num_azimuths": {
"type": "integer",
"multipleOf": 2,
"minimum": 2,
"maximum": 64
},
"num_polars": {
"type": "integer",
"enum": [2, 3, 4]
},
"track_density": {
"type": "number",
"minimum": 0.001,
"maximum": 1.0
},
"type": {
"type": "string",
"enum": ["LCMD", "TYPL", "DECT"]
},
"source_type": {
"type": "string",
"enum": ["LINEAR", "FLAT"]
},
}
},
"moc_1d": {
"type": "object",
"properties": {
"num_polars": {
"type": "integer",
"enum": [1, 2, 4, 8, 16]
},
"max_fine_mesh_thickness": {
"type": "number",
"minimum": 0.1,
"maximum": 10
},
"num_inner_iterations": {
"type": "integer",
"minimum": 1,
"maximum": 100
},
}
},
"cmfd": {
"type": "object",
"properties": {
"cmfd_on": {"type": "boolean"},
"fission_converge_criterion": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"keff_converge_criterion": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 1.0
},
"max_num_inner_iterations": {
"type": "integer",
"minimum": 1,
"maximum": 9999
},
"max_num_outer_iterations": {
"type": "integer",
"minimum": 1,
"maximum": 9999
},
}
},
"critical_boron_search": {
"type": "object",
"properties": {
"cb_search_on": {"type": "boolean"},
"boron_converge_criterion": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 10.0,
},
}
},
"xe_transients": {
"type": "string",
"enum": ["EQUI", "ZERO", "TRAN"]
},
"rod_decusping_method": {
"type": "string",
"enum": ["VOLUME_WEIGHT", "AF_WEIGHT", "NSI_WEIGHT", "DIRECT"]
},
"energy_deposition": {
"type": "string",
"enum": ["HEATING_LOCAL", "KAPPA_FISSION"]
},
"output": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["MINIMAL", "MEDIUM", "MAXIMUM"],
}
}
},
},
"required": []
}
STATE_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"boron_concentration": BORON,
"boron_10_abundance": {
"type": "number",
"minimum": 0.0,
"maximum": 100.0,
},
"total_power": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 10000.0
},
"relative_power": {
"type": "number",
"minimum": 0.0,
"maximum": 2.0,
},
"system_pressure": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 50.0
},
"inlet_temperature": TEMPERATURE,
"fuel_temperature": TEMPERATURE,
"moderator_temperature": TEMPERATURE,
"inlet_mass_flow_rate": {
"type": "number",
"exclusiveMinimum": 0.0,
"maximum": 50000.0
},
"relative_inlet_flow": {
"type": "number",
"minimum": 0.0,
"maximum": 2.0
},
"power_density": {
"type": "number",
"minimum": 0.0,
"maximum": 1000.0,
},
},
"required": ["boron_concentration", "system_pressure"],
"anyOf": [
{"required": ["boron_concentration", "inlet_temperature", "system_pressure"]},
{"required": ["boron_concentration", "moderator_temperature", "fuel_temperature", "system_pressure"]}
],
"error_msg": "control_rod defination require either 'inlet_temperature' or 'mod_temperature' and 'fuel_temperature'"
}
CONTROL_ROD_POSITION = {
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
},
"minItems": 1
}
LPPT_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"criticals": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"boron_concentration": BORON,
"fuel_temperature": TEMPERATURE,
"moderator_temperature": TEMPERATURE,
"control_rod_position": CONTROL_ROD_POSITION
},
"required": ["name"]
},
},
"temperature_coefficients": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"types": {
"type": "array",
"items": {
"type": "string",
"enum": ["ITC", "MTC", "FTC"]
},
"minItems": 1
},
"boron_concentration": BORON,
"delta_temperature": TEMPERATURE,
"control_rod_position": CONTROL_ROD_POSITION
},
"required": ["name", "types"]
},
},
"control_rod_worths": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"boron_concentration": BORON,
"fuel_temperature": TEMPERATURE,
"moderator_temperature": TEMPERATURE,
"control_rod_position": CONTROL_ROD_POSITION
},
"required": ["name", "control_rod_position"]
},
},
"control_rod_worths_curve": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"boron_concentration": BORON,
"fuel_temperature": TEMPERATURE,
"moderator_temperature": TEMPERATURE,
"steps": {
"type": "array",
"items": {
"type": "object",
"properties": {
"step": {
"type": "integer",
"minimum": 0
},
"control_rod_position": CONTROL_ROD_POSITION,
},
"required": ["step", "control_rod_position"]
},
"minItems": 1,
},
},
"required": ["name", "steps"]
},
},
},
}
DEPLETION_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"time_step_units": {
"type": "string",
"enum": ["MWd/tU", "EFPD", "DAY"]
},
"coupling_strategy": {
"type": "string",
"enum": ["PREDICTOR", "PREDICTOR_CORRECTOR", "LINEAR_RATE", "LOG_LINEAR_RATE"],
},
"burnup_points": {
"type": "array",
"items": {
"type": "number",
"minimum": 0.0,
},
"minItems": 1
},
"states": {
"type": "array",
"items": {
"type": "object",
"properties": {
"burnup": {
"type": "number",
"minimum": 0.0,
},
"delta_time": {
"type": "number",
"minimum": 0.0,
},
"boron_concentration": BORON,
"boron_10_abundance": {
"type": "number",
"minimum": 0.0,
"maximum": 100.0,
},
"inlet_temperature": TEMPERATURE,
"moderator_temperature": TEMPERATURE,
"fuel_temperature": TEMPERATURE,
"relative_power": {
"type": "number",
"minimum": 0.0,
"maximum": 2.0,
},
"relative_inlet_flow": {
"type": "number",
"minimum": 0.0,
"maximum": 2.0,
},
"is_averaged": {
"type": "boolean",
},
"save_restart_file": {
"type": "boolean",
},
"critical_boron_search": {
"type": "boolean",
},
"thermal_coupling": {
"type": "boolean",
},
"xe_transients": {
"type": "string",
"enum": ["EQUI", "ZERO", "TRAN"]
},
"sm_transients": {
"type": "string",
"enum": ["EQUI", "ZERO", "TRAN"]
},
"output_type": {
"type": "string",
"enum": ["MINIMAL", "MEDIUM", "MAXIMUM"],
},
"control_rod_position": CONTROL_ROD_POSITION
},
"required": ["burnup"]
},
"minItems": 1
},
},
"oneOf": [
{"required": ["burnup_points"]},
{"required": ["states"]},
],
"error_msg": "depletion defination require either 'states' or 'burnup_points'"
}
INPUT_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"copy_from": {
"type": "string",
},
"materials": {
"type": "array",
"items": MATERIAL_SCHEMA,
"minItems": 1
},
"geometries": {
"type": "object",
"properties": {
"structures": {
"type": "array",
"items": STRUCTURE_SCHEMA,
"minItems": 1
},
"lattices": {
"type": "array",
"items": LATTICE_SCHEMA,
"minItems": 1
},
"grids": {
"type": "array",
"items": GRID_SLICE_SCHEMA,
"minItems": 1
},
"baffles": {
"type": "array",
"items": BAFFLE_SLICE_SCHEMA,
"minItems": 1
},
"assemblies": {
"type": "array",
"items": ASSEMBLY_SCHEMA,
"minItems": 1
},
"inserted_rods": {
"type": "array",
"items": INSERTED_ROD_SCHEMA,
"minItems": 1
},
"instrument_bundle": {
"type": "array",
"items": INSERTED_ROD_ASSEMBLY_BUNDLE_SCHEMA,
"minItems": 1
},
"burnable_absorber_bundle": {
"type": "array",
"items": INSERTED_ROD_ASSEMBLY_BUNDLE_SCHEMA,
"minItems": 1
},
"control_rod_bundle": {
"type": "array",
"items": INSERTED_ROD_ANYWHERE_BUNDLE_SCHEMA,
"minItems": 1
},
"core": CORE_SCHEMA,
},
"required": ["structures", "lattices", "assemblies", "core"],
},
"state": STATE_SCHEMA,
"settings": SETTINGS_SCHEMA,
"low_power_physic_tests": LPPT_SCHEMA,
"depletion": DEPLETION_SCHEMA,
},
"required": ["materials", "geometries"],
}