Проектирование распределителей ДСТ
Author
# parameters_exporter.jl
"""
assign_region_fields!(params, i, reg)
Заполняет параметры i-й области в соответствии с системным дампом Engee.
"""
function assign_region_fields!(params, i, reg)
if reg.shape == "circular"
params["region_shape_$i"] = "Circular"
params["circle_diameter_$i"] = Dict("value" => string(Float64(reg.width_end)), "unit" => "mm")
params["minor_segment_length_$i"] = Dict("value" => "0.0", "unit" => "mm")
params["major_segment_length_$i"] = Dict("value" => string(Float64(reg.length)), "unit" => "mm")
params["radial_depth_$i"] = Dict("value" => string(Float64(reg.radial_depth_start)), "unit" => "mm")
elseif reg.shape == "triangular"
params["region_shape_$i"] = "Triangular"
calculated_angle = 2.0 * atand((reg.width_end - reg.width_start) / (2.0 * reg.length))
params["triangle_angle_$i"] = Dict("value" => string(Float64(calculated_angle)), "unit" => "deg")
params["triangle_width_$i"] = Dict("value" => string(Float64(reg.width_end)), "unit" => "mm")
params["radial_depth_$i"] = Dict("value" => string(Float64(reg.radial_depth_start)), "unit" => "mm")
elseif reg.shape == "rectangular"
params["region_shape_$i"] = "Rectangular"
params["rectangle_width_$i"] = Dict("value" => string(Float64(reg.width_start)), "unit" => "mm")
params["rectangle_length_$i"] = Dict("value" => string(Float64(reg.length)), "unit" => "mm")
params["radial_depth_$i"] = Dict("value" => string(Float64(reg.radial_depth_start)), "unit" => "mm")
if reg.radial_depth_start == reg.radial_depth_end
params["radial_depth_type_$i"] = "Constant"
else
params["radial_depth_type_$i"] = "Linear"
slope_angle = atand((reg.radial_depth_end - reg.radial_depth_start) / reg.length)
params["angle_with_spool_axis_$i"] = Dict("value" => string(Float64(slope_angle)), "unit" => "deg")
end
elseif reg.shape == "trapezoidal"
params["region_shape_$i"] = "Trapezoidal"
params["trapezoid_initial_width_$i"] = Dict("value" => string(Float64(reg.width_start)), "unit" => "mm")
params["trapezoid_final_width_$i"] = Dict("value" => string(Float64(reg.width_end)), "unit" => "mm")
calculated_angle = atand((reg.width_end - reg.width_start) / (2.0 * reg.length))
params["trapezoid_angle_$i"] = Dict("value" => string(Float64(calculated_angle)), "unit" => "deg")
params["radial_depth_$i"] = Dict("value" => string(Float64(reg.radial_depth_start)), "unit" => "mm")
elseif reg.shape == "trapezoidal_rounded"
params["region_shape_$i"] = "Trapezoidal with rounded edges"
params["trapezoid_with_rounded_sides_initial_width_$i"] = Dict("value" => string(Float64(reg.width_start)), "unit" => "mm")
params["trapezoid_with_rounded_sides_final_width_$i"] = Dict("value" => string(Float64(reg.width_end)), "unit" => "mm")
params["trapezoid_with_rounded_sides_axial_length_$i"] = Dict("value" => string(Float64(reg.length)), "unit" => "mm")
params["trapezoid_with_rounded_sides_side_diameter_$i"] = Dict("value" => string(Float64(reg.r_edge * 2.0)), "unit" => "mm")
params["radial_depth_$i"] = Dict("value" => string(Float64(reg.radial_depth_start)), "unit" => "mm")
end
end
"""
send_params_to_engee(comp::SpoolComponent)
Передает параметры объекта SpoolComponent напрямую в блоки Engee через set_param!
"""
function send_params_to_engee(comp::SpoolComponent)
total_notch_width = isempty(comp.regions) ? 6.0 : sum(reg.length for reg in comp.regions)
calculated_spool_length = total_notch_width + abs(comp.underlap) + 15.0
chosen_orientation = "Positive relative rod displacement opens orifice"
str_evalanarea = comp.enable_annular_area ? "true" : "false"
str_pVeval = "false"
str_couette = "false"
str_jet_coef = "0.0"
params = Dict{String, Any}(
"opening_orientation" => chosen_orientation,
"moving_case" => "false",
"enable_annular_area" => str_evalanarea,
"enable_pressure_force_and_volume_variation" => str_pVeval,
"couette_effect" => str_couette,
"notch_count" => string(Int64(comp.nslots)),
"region_count" => string(Int64(length(comp.regions))),
"spool_diameter" => Dict("value" => string(Float64(comp.spool_diameter)), "unit" => "mm"),
"rod_diameter" => Dict("value" => string(Float64(comp.rod_diameter)), "unit" => "mm"),
"chamber_length_offset" => Dict("value" => string(Float64(comp.chamber_length_0)), "unit" => "mm"),
"offset" => Dict("value" => string(Float64(comp.underlap)), "unit" => "mm"),
"clearance" => Dict("value" => string(Float64(comp.clearance)), "unit" => "mm"),
"eccentricity_ratio" => Dict("value" => string(Float64(comp.eccentricity_ratio)), "unit" => ""),
"spool_length" => Dict("value" => string(Float64(calculated_spool_length)), "unit" => "mm"),
"orifice_opening_at_max_area" => Dict("value" => string(Float64(comp.underlap_max_area)), "unit" => "mm"),
"jet_angle" => Dict("value" => "69.0", "unit" => "deg"),
"jet_force_coefficient" => str_jet_coef,
"C_q_max" => "0.7",
"critical_flow_number" => "100.0",
"enable_discontinuity_handling" => "false",
"discretization_interval_count" => "10"
)
try engee.set_param!(comp.block_path, "region_count" => params["region_count"]) catch e end
for (i, reg) in enumerate(comp.regions)
if i > length(comp.regions) break end
assign_region_fields!(params, i, reg)
end
function get_param_priority(key)
if key == "moving_case" return 0
elseif key == "opening_orientation" return 1
elseif key == "region_count" return 2
elseif startswith(key, "region_shape") return 3
elseif startswith(key, "radial_depth_type") return 4
else return 5
end
end
sorted_keys = sort(collect(keys(params)), by = get_param_priority)
for param_name in sorted_keys
val = params[param_name]
try engee.set_param!(comp.block_path, param_name => val) catch e end
end
end