VeraGridEngine.Utils packageο
Subpackagesο
- VeraGridEngine.Utils.Filtering package
- Submodules
- VeraGridEngine.Utils.Filtering.filtering module
- VeraGridEngine.Utils.Filtering.objects_filtering module
- VeraGridEngine.Utils.Filtering.results_table_filtering module
- VeraGridEngine.Utils.Filtering.timeseries_filtering module
- Module contents
- VeraGridEngine.Utils.MIP package
- Subpackages
- Submodules
- VeraGridEngine.Utils.MIP.gslv_interface module
- VeraGridEngine.Utils.MIP.mip_interface_template module
AbstractLpModelAbstractLpModel.INFINITYAbstractLpModel.OPTIMALAbstractLpModel.add_bin()AbstractLpModel.add_cst()AbstractLpModel.add_int()AbstractLpModel.add_var()AbstractLpModel.fobj_value()AbstractLpModel.get_dual_value()AbstractLpModel.get_value()AbstractLpModel.is_mip()AbstractLpModel.loggerAbstractLpModel.minimize()AbstractLpModel.model_as_string()AbstractLpModel.nameAbstractLpModel.originally_infeasibleAbstractLpModel.relaxed_slacksAbstractLpModel.save_model()AbstractLpModel.set_var_bounds()AbstractLpModel.solve()AbstractLpModel.solver_typeAbstractLpModel.status2string()AbstractLpModel.sum()
- VeraGridEngine.Utils.MIP.ortools_interface module
- VeraGridEngine.Utils.MIP.pulp_interface module
PulpLpModelPulpLpModel.INFINITYPulpLpModel.OPTIMALPulpLpModel.add_bin()PulpLpModel.add_cst()PulpLpModel.add_int()PulpLpModel.add_var()PulpLpModel.fobj_value()PulpLpModel.get_dual_value()PulpLpModel.get_solver()PulpLpModel.get_value()PulpLpModel.is_mip()PulpLpModel.minimize()PulpLpModel.modelPulpLpModel.model_as_string()PulpLpModel.save_model()PulpLpModel.set_var_bounds()PulpLpModel.solve()PulpLpModel.status2string()PulpLpModel.sum()
get_lp_var_value()get_pulp_available_mip_solvers()
- VeraGridEngine.Utils.MIP.selected_interface module
- Module contents
- VeraGridEngine.Utils.NumericalMethods package
- Submodules
- VeraGridEngine.Utils.NumericalMethods.MVRSM_mo_pareto module
MVRSM_mo_pareto()SurrogateModelSurrogateModel.PSurrogateModel.WSurrogateModel.augmented_Tchebycheff()SurrogateModel.augmented_Tchebycheff_jac()SurrogateModel.bSurrogateModel.boundsSurrogateModel.cSurrogateModel.g()SurrogateModel.g_jac()SurrogateModel.g_scalarize()SurrogateModel.g_scalarize_jac()SurrogateModel.g_scalarize_max()SurrogateModel.g_scalarize_max_jac()SurrogateModel.init()SurrogateModel.mSurrogateModel.minimum()SurrogateModel.n_objSurrogateModel.phi()SurrogateModel.phi_deriv()SurrogateModel.scratchSurrogateModel.update()
get_norm_factors()inv_normalize_md()inv_scale()normalize_md()relu()relu_deriv()scale()
- VeraGridEngine.Utils.NumericalMethods.MVRSM_mo_scaled module
- VeraGridEngine.Utils.NumericalMethods.MVRSM_original module
- VeraGridEngine.Utils.NumericalMethods.autodiff module
- VeraGridEngine.Utils.NumericalMethods.common module
- VeraGridEngine.Utils.NumericalMethods.emt_sparse_solver_loader module
- VeraGridEngine.Utils.NumericalMethods.emt_sparse_solver_registry module
- VeraGridEngine.Utils.NumericalMethods.emt_sparse_superlu_backend module
- VeraGridEngine.Utils.NumericalMethods.external_sparse_solver_interface module
SparseLinearFactorizationHandleSparseLinearSolverBackendSparseLinearSolverBackend.analyze()SparseLinearSolverBackend.factorize()SparseLinearSolverBackend.get_backend_stats()SparseLinearSolverBackend.get_name()SparseLinearSolverBackend.get_solver_type()SparseLinearSolverBackend.is_available()SparseLinearSolverBackend.refactor_numeric()SparseLinearSolverBackend.requires_csc()SparseLinearSolverBackend.supports_numeric_refactorization()SparseLinearSolverBackend.supports_symbolic_analysis_reuse()
SparseLinearSolverBackendProvider
- VeraGridEngine.Utils.NumericalMethods.ips module
IpsFunctionReturnIpsFunctionReturn.GIpsFunctionReturn.GxIpsFunctionReturn.GxxIpsFunctionReturn.HIpsFunctionReturn.HxIpsFunctionReturn.HxxIpsFunctionReturn.SIpsFunctionReturn.SfIpsFunctionReturn.StIpsFunctionReturn.compare()IpsFunctionReturn.fIpsFunctionReturn.fxIpsFunctionReturn.fxxIpsFunctionReturn.get_data()IpsFunctionReturn.get_headers()
IpsSolutioncalc_ccond()calc_error()calc_feascond()calc_gradcond()calc_ocond()interior_point_solver()max_abs()split()step_calculation()
- VeraGridEngine.Utils.NumericalMethods.iwamoto module
- VeraGridEngine.Utils.NumericalMethods.levenberg_marquadt module
- VeraGridEngine.Utils.NumericalMethods.newton_raphson module
- VeraGridEngine.Utils.NumericalMethods.newton_raphson_ode module
- VeraGridEngine.Utils.NumericalMethods.non_dominated_sorting module
- VeraGridEngine.Utils.NumericalMethods.nsga3 module
- VeraGridEngine.Utils.NumericalMethods.numerical_stability module
- VeraGridEngine.Utils.NumericalMethods.powell module
- VeraGridEngine.Utils.NumericalMethods.sparse_solve module
- VeraGridEngine.Utils.NumericalMethods.weldorf_online_stddev module
- Module contents
- VeraGridEngine.Utils.Sparse package
- Submodules
- VeraGridEngine.Utils.Sparse.csc module
- VeraGridEngine.Utils.Sparse.csc2 module
CSCCxCSCcsc_add_cx2()csc_add_cx3()csc_add_ff()csc_add_ff2()csc_cumsum_i()csc_matvec_cx()csc_matvec_ff()csc_multiply_cx()csc_multiply_ff()csc_multiply_ff2()csc_scatter_cx()csc_scatter_f()csc_spalloc_cx()csc_spalloc_f()csc_stack_2d_ff()diagc()diags()extend()mat_to_scipy()pack_3_by_4()pack_4_by_4()scipy_to_cxmat()scipy_to_mat()sp_slice()sp_slice_cols()sp_slice_rows()sp_transpose()spfactor()spsolve_csc()
- VeraGridEngine.Utils.Sparse.csc_numba module
binary_find()coo_to_csc()csc_add_ff()csc_cumsum_i()csc_diagonal()csc_diagonal_from_array()csc_diagonal_from_complex_array()csc_diagonal_from_number()csc_mat_vec_ff()csc_multiply_ff()csc_norm()csc_scatter_f()csc_scatter_ff()csc_spalloc_f()csc_sprealloc_f()csc_stack_2d_ff_col_major()csc_stack_2d_ff_row_major()csc_stack_3_by_4_ff()csc_stack_4_by_4_ff()csc_sub_matrix()csc_sub_matrix_cols()csc_sub_matrix_old()csc_sub_matrix_rows()csc_to_csr()csc_to_dense()csc_transpose()dense_to_csc_numba()diag_positions()find_islands()get_sparse_array_numba()ialloc()sp_submat_c_numba()xalloc()
- VeraGridEngine.Utils.Sparse.sparse_array module
SparseArraySparseArray.at()SparseArray.clear()SparseArray.copy()SparseArray.create()SparseArray.create_from_array()SparseArray.create_from_dict()SparseArray.default_valueSparseArray.dtypeSparseArray.fill()SparseArray.get_map()SparseArray.get_sparse_representation()SparseArray.get_sparsity()SparseArray.info()SparseArray.insert()SparseArray.resample()SparseArray.resize()SparseArray.set_data()SparseArray.set_sparse_data_from_data()SparseArray.size()SparseArray.slice()SparseArray.toarray()
SparseObjectArraycheck_type()
- VeraGridEngine.Utils.Sparse.utils module
- Module contents
- VeraGridEngine.Utils.Symbolic package
- Submodules
- VeraGridEngine.Utils.Symbolic.block module
BlockBlock.E()Block.V()Block.add()Block.can_use_bulk_connect_update()Block.check_empty()Block.check_valid_init_method()Block.compare()Block.connect()Block.copy()Block.diagramBlock.empty()Block.find_var_in_block()Block.find_var_in_equations()Block.get_all_blocks()Block.get_all_equations_list()Block.get_all_vars()Block.get_vars()Block.merge_incoming_block()Block.parse()Block.remove()Block.set_parameter_in_model()Block.to_dict()Block.unify_blocks()Block.update_equations()Block.update_equations_bulk()Block.update_model()Block.update_model_bulk()Block.update_variables()Block.update_variables_bulk()
build_name_to_var_lookup()compare_blocks_structurally()compare_n_blocks_structurally()find_connections()find_name_in_block()set_parameter()variables_in_corresponding_attributes()
- VeraGridEngine.Utils.Symbolic.block_helpers module
- VeraGridEngine.Utils.Symbolic.bus_emt_template module
BusEmtTemplateBusEmtTemplate.CLASS_NON_EDITABLE_PROPERTIESBusEmtTemplate.CLASS_PROPERTIES_WITH_PROFILEBusEmtTemplate.CLASS_PROPERTY_DECLARATIONSBusEmtTemplate.CLASS_PROPERTY_LISTBusEmtTemplate.CLASS_REGISTERED_PROPERTIESBusEmtTemplate.blockBusEmtTemplate.tpeBusEmtTemplate.v_ABusEmtTemplate.v_BBusEmtTemplate.v_CBusEmtTemplate.v_DCBusEmtTemplate.v_N
get_bus_emt_algebraic_vars()get_bus_emt_template()
- VeraGridEngine.Utils.Symbolic.bus_rms_template module
- VeraGridEngine.Utils.Symbolic.compare_expressions_structure module
- VeraGridEngine.Utils.Symbolic.compiled_functions module
- VeraGridEngine.Utils.Symbolic.diagnostic module
Array1DNewtonDiagnosticsConfigNewtonDiagnosticsConfig.backtracking_betaNewtonDiagnosticsConfig.backtracking_max_iterNewtonDiagnosticsConfig.backtracking_min_alphaNewtonDiagnosticsConfig.compute_dense_condNewtonDiagnosticsConfig.dense_cond_max_nNewtonDiagnosticsConfig.dense_cond_warnNewtonDiagnosticsConfig.enable_backtrackingNewtonDiagnosticsConfig.enable_fallbackNewtonDiagnosticsConfig.enable_index1_checkNewtonDiagnosticsConfig.index1_fail_pivot_ratioNewtonDiagnosticsConfig.index1_max_block_nNewtonDiagnosticsConfig.index1_warn_pivot_ratioNewtonDiagnosticsConfig.log_levelNewtonDiagnosticsConfig.step_norm_explode
NewtonSolveContextNewtonSolveContext.cond_estNewtonSolveContext.failure_msgNewtonSolveContext.index1_pivot_ratioNewtonSolveContext.methodNewtonSolveContext.newton_iterNewtonSolveContext.phaseNewtonSolveContext.res_norm_infNewtonSolveContext.solverNewtonSolveContext.step_idxNewtonSolveContext.step_norm2NewtonSolveContext.step_norm_infNewtonSolveContext.tNewtonSolveContext.used_fallback
NewtonTraceCollectordense_lstsq_fallback()maybe_apply_backtracking()maybe_check_index1()sparse_lsqr_fallback()with_newton_diagnostics()
- VeraGridEngine.Utils.Symbolic.explicit_initialization_symbolic module
RmsSingleEquationCompilerSymbolicVectorSingleEquationCompileradd_items()build_explicit_init_graph()build_init_dict()build_rms_single_equation_compiler()build_symbolic_vector_single_equation_compiler()build_uid_bindings()compile_single_explicit_equation()evaluate_explicit_init_equation()evaluate_single_equation_fn()init_explicit_common()solve_self_implicit()store_resolved_event_parameter()
- VeraGridEngine.Utils.Symbolic.jit_compiler module
- Module: JIT Equation Compiler & Numerical Discretization Engine
ADVisitorBDF2MethodBackwardEulerMethodContinuousMethodDerivativeFunctionWrapperDiscretizationMethodEagerEquationCompilerEagerKernelKindEmptySparseJacobianEvaluatorEmptyVecSparseJacobianEvaluatorEquationCompilerEventParameterFunctionWrapperGeneratedKernelCacheGeneratedKernelCacheEntryMatrixVectorizedCompilerMatrixVectorizedVisitorRMSCompilerRMSCompilerVecSparseJacobianEvaluatorVecWrapperSparseJacobianEvaluatorWrapperSubexpressionAnalyzerSubexpressionAnalyzer.analyze()SubexpressionAnalyzer.expr_complexitySubexpressionAnalyzer.expr_countsSubexpressionAnalyzer.expr_objectsSubexpressionAnalyzer.hash_expr()SubexpressionAnalyzer.memo_canonicalSubexpressionAnalyzer.memo_complexitySubexpressionAnalyzer.thresholdSubexpressionAnalyzer.visited_traversal
SymbolicToPythonVisitorSymbolicToPythonVisitor.OP_PRECEDENCESymbolicToPythonVisitor.analyzerSymbolicToPythonVisitor.cse_mapSymbolicToPythonVisitor.generic_visit()SymbolicToPythonVisitor.in_cse_defSymbolicToPythonVisitor.methodSymbolicToPythonVisitor.param_mapSymbolicToPythonVisitor.var_mapSymbolicToPythonVisitor.visit()SymbolicToPythonVisitor.visit_binop()SymbolicToPythonVisitor.visit_const()SymbolicToPythonVisitor.visit_diffvar()SymbolicToPythonVisitor.visit_func()SymbolicToPythonVisitor.visit_unop()SymbolicToPythonVisitor.visit_var()
TrapezoidalMethod
- VeraGridEngine.Utils.Symbolic.lp_model module
- VeraGridEngine.Utils.Symbolic.static_parameter_mapping module
abc_to_nabc()add_static_mapping_warning()api_mapping_has_any_key()assign_3x3_static_matrix()assign_api_mapping_value_if_present()assign_battery_static_api_mapping()assign_common_branch_static_api_mapping()assign_common_injection_static_api_mapping()assign_controllable_shunt_static_api_mapping()assign_current_injection_static_api_mapping()assign_dc_line_static_api_mapping()assign_external_grid_static_api_mapping()assign_generator_static_api_mapping()assign_hvdc_line_static_api_mapping()assign_line_static_api_mapping()assign_load_static_api_mapping()assign_series_reactance_static_api_mapping()assign_shunt_static_api_mapping()assign_static_api_object_mapping_for_device()assign_static_generator_static_api_mapping()assign_switch_static_api_mapping()assign_transformer2w_static_api_mapping()assign_upfc_static_api_mapping()assign_vsc_static_api_mapping()balanced_to_abc_power()boolean_to_float()build_line_static_matrices()build_uncoupled_line_static_matrices()compute_transformer_equivalent_circuit_values()controllable_shunt_mode_code()converter_control_code()external_grid_mode_code()flatten_matrix_keys()frequency_base_hz_from_grid()get_all_line_matrix_keys()get_current_injection_phase_values_pu_abc()get_line_active_global_indices()get_line_c_keys()get_line_linv_keys()get_line_r_keys()get_load_current_phase_values_pu_abc()get_load_impedance_phase_values_pu_abc()get_load_power_phase_values_pu_abc()get_shunt_phase_values_pu_abc()get_transformer_equivalent_circuit_derived_keys()get_transformer_from_connection_keys()get_transformer_to_connection_keys()mvar_to_pu_on_grid_base()mw_to_pu_on_grid_base()omega_base_from_grid()shunt_connection_code()to_static_mapping_const()transformer_equivalent_circuit_values_are_requested()validate_line_static_matrices()xfmr_connection_matrix()xfmr_phase_permutation_matrix()
- VeraGridEngine.Utils.Symbolic.static_parameter_mapping_rms module
abc_to_nabc()add_static_mapping_warning()api_mapping_has_any_key()assign_3x3_static_matrix()assign_api_mapping_value_if_present()assign_battery_static_api_mapping()assign_common_branch_static_api_mapping()assign_common_injection_static_api_mapping()assign_controllable_shunt_static_api_mapping()assign_current_injection_static_api_mapping()assign_dc_line_static_api_mapping()assign_external_grid_static_api_mapping()assign_generator_static_api_mapping()assign_hvdc_line_static_api_mapping()assign_line_static_api_mapping()assign_load_static_api_mapping()assign_series_reactance_static_api_mapping()assign_shunt_static_api_mapping()assign_static_api_object_mapping_for_device()assign_static_generator_static_api_mapping()assign_switch_static_api_mapping()assign_transformer2w_static_api_mapping()assign_upfc_static_api_mapping()assign_vsc_static_api_mapping()balanced_to_abc_power()build_line_static_matrices()build_uncoupled_line_static_matrices()compute_transformer_equivalent_circuit_values()controllable_shunt_mode_code()converter_control_code()external_grid_mode_code()flatten_matrix_keys()get_all_line_matrix_keys()get_current_injection_phase_values_pu_abc()get_line_active_global_indices()get_line_c_keys()get_line_linv_keys()get_line_r_keys()get_load_current_phase_values_pu_abc()get_load_impedance_phase_values_pu_abc()get_load_power_phase_values_pu_abc()get_shunt_phase_values_pu_abc()get_transformer_equivalent_circuit_derived_keys()get_transformer_from_connection_keys()get_transformer_to_connection_keys()shunt_connection_code()transformer_equivalent_circuit_values_are_requested()validate_line_static_matrices()xfmr_connection_matrix()xfmr_phase_permutation_matrix()
- VeraGridEngine.Utils.Symbolic.symbolic module
BinOpCmpOpComparisonConstExprFuncFunc2SharedVarReferenceTypeUnOpVarabs()acos()asin()atan()atan2()cos()cosh()diff()eval_uid()exp()expression2numba()f_exc()find_vars_order()get_expression_vars()get_namespace()get_symbolic_parser_function_names()hard_sat()heaviside()heaviside_num()log()piecewise()sin()sinh()sqrt()string_to_symbolic()symbolic_to_string()tan()
- VeraGridEngine.Utils.Symbolic.symbolic_io module
- VeraGridEngine.Utils.Symbolic.symbolic_ml module
- VeraGridEngine.Utils.Symbolic.templates_common_functions module
connect_bus_variables_emt()connect_bus_variables_rms()connect_injection_emt()connect_line_emt_from()connect_line_emt_to()connect_line_phasor_rms_from()connect_line_phasor_rms_to()connect_line_rms_from()connect_line_rms_to()connect_models()connect_models_power_flow()connect_pending_injection_bus_variables_emt()connect_vsc_emt_from()connect_vsc_emt_to()set_emt_model()set_rms_model()
- VeraGridEngine.Utils.Symbolic.test_symbolic_equivalence module
BinOpConstFuncUnOpVarcanonical()cos()equations_equivalent()equivalent()equivalent_expanded()equivalent_systems()expand()expand_and_canonicalize()run_all_tests()sin()structural_hash()structural_hash_expanded()test_associativity()test_associativity_mult()test_commutativity()test_commutativity_mult()test_complex_expression()test_constant_folding()test_equations_equivalent()test_function_stability()test_neutral_elements()test_polynomial_equivalence()test_power_normalization()test_system_equivalence()test_zero_product()
- VeraGridEngine.Utils.Symbolic.test_variable_alignment module
- VeraGridEngine.Utils.Symbolic.variable_alignment_engine module
- Module contents
- VeraGridEngine.Utils.ThirdParty package
Submodulesο
VeraGridEngine.Utils.emt_boundary_update_wrapper moduleο
- class VeraGridEngine.Utils.emt_boundary_update_wrapper.BoundaryUpdateWrapper[source]ο
Bases:
objectLightweight interface for EMT boundary updates and forced events.
The class lives in
VeraGridEngine.Utilsso EMT templates, procedural logic and solver modules can import it statically without pulling one heavy solver or simulation package__init__into the import graph.
VeraGridEngine.Utils.procedural_logic moduleο
- class VeraGridEngine.Utils.procedural_logic.AnalogFlipFlopLogic(output_var_name: str, input_expr: Expr | Comparison, set_expr: Expr | Comparison, reset_expr: Expr | Comparison, name: str = '')[source]ο
Bases:
ProceduralLogicBaseStore an analog value when a set/reset latch enters the high state.
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the runtime output slot and reset the analog latch state.
- Parameters:
problem β Bound EMT problem.
- Returns:
None
- held_valueο
- initializedο
- input_exprο
- logic_tpe = 'analog_flipflop'ο
- output_idxο
- output_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) AnalogFlipFlopLogic[source]ο
Clone the logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped analog flip-flop logic.
- reset_exprο
- set_exprο
- stateο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Apply analog set/reset semantics and update the held value.
- Parameters:
t β Current solver time.
x β Accepted state vector.
params β Runtime parameter vector.
- Returns:
None
- class VeraGridEngine.Utils.procedural_logic.BlockProceduralLogicUpdater(problem: EmtProblemTemplate, logic_entries: List[ProceduralLogicBase])[source]ο
Bases:
BoundaryUpdateWrapperBoundary updater that delegates runtime decisions to block-attached procedural logic entries.
- get_next_forced_event_time(t_prev: float, t_target: float) float | None[source]ο
Return the earliest forced event requested by any procedural logic entry.
- Parameters:
t_prev β Previous solver time.
t_target β Nominal target time.
- Returns:
Earliest event in the interval, if any.
- logic_entriesο
- problemο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Forward one runtime update to all procedural logic entries.
- Parameters:
t β Current solver time.
x β Accepted state vector.
params β Runtime parameter vector.
- Returns:
None
- class VeraGridEngine.Utils.procedural_logic.DelayedThresholdLatchLogic(monitored_var_name: str, mode_var_name: str, threshold: float, delay: float, reset_delay: float | None = None, name: str = '')[source]ο
Bases:
ProceduralLogicBaseComparator + timer + latch procedural logic for runtime modes.
The logic watches one state variable, arms a timer when a threshold is crossed, applies a mode change after a delay, and optionally resets after a second delay.
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the monitored state and runtime mode indices.
- Parameters:
problem β Bound EMT problem.
- Returns:
None
- delayο
- get_next_forced_event_time(t_prev: float, t_target: float) float | None[source]ο
Return the next exact trip or reset event inside one solver step.
- Parameters:
t_prev β Previous solver time.
t_target β Nominal target time.
- Returns:
First pending event in the interval, if any.
- get_trace_arrays() Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray][source]ο
Return the internal trace arrays as dense numpy arrays.
- Returns:
Tuple with times, measurements, comparator, timer, latch, and mode traces.
- last_t_prev: float | Noneο
- logic_tpe = 'delayed_threshold_latch'ο
- mode_idxο
- mode_var_nameο
- monitored_idxο
- monitored_var_nameο
- pending_reset_time: float | Noneο
- pending_trip_time: float | Noneο
- pickup_time: float | Noneο
- remap(var_mapping: Dict[Expr | str, Expr]) DelayedThresholdLatchLogic[source]ο
Clone the logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped delayed-threshold latch logic.
- reset_applied_solver_time: float | Noneο
- reset_applied_time: float | Noneο
- reset_delayο
- thresholdο
- trace_comparator: List[float]ο
- trace_latched: List[float]ο
- trace_measure: List[float]ο
- trace_mode: List[float]ο
- trace_t: List[float]ο
- trace_timer_armed: List[float]ο
- trip_applied_solver_time: float | Noneο
- trip_applied_time: float | Noneο
- trippedο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Advance the delayed-threshold latch logic and tracing state.
- Parameters:
t β Current solver time.
x β Accepted state vector.
params β Runtime parameter vector.
- Returns:
None
- class VeraGridEngine.Utils.procedural_logic.FixedSampleLogic(output_var_name: str, condition_expr: Expr | Comparison, name: str = '')[source]ο
Bases:
ProceduralLogicBaseRetain the initial truth value of one condition in a runtime mode variable.
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the runtime output slot for this logic entry.
- Parameters:
problem β Bound EMT problem.
- Returns:
None
- condition_exprο
- initializedο
- logic_tpe = 'fixed_sample'ο
- output_idxο
- output_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) FixedSampleLogic[source]ο
Clone the logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped fixed-sample logic.
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Sample the condition once and keep it fixed afterwards.
- Parameters:
t β Current solver time.
x β Accepted state vector.
params β Runtime parameter vector.
- Returns:
None
- class VeraGridEngine.Utils.procedural_logic.FlipFlopLogic(output_var_name: str, set_expr: Expr | Comparison, reset_expr: Expr | Comparison, name: str = '')[source]ο
Bases:
ProceduralLogicBaseStore a binary set/reset latch in a runtime mode variable.
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the runtime output slot for the latch state.
- Parameters:
problem β Bound EMT problem.
- Returns:
None
- initializedο
- logic_tpe = 'flipflop'ο
- output_idxο
- output_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) FlipFlopLogic[source]ο
Clone the logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped flip-flop logic.
- reset_exprο
- set_exprο
- stateο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Apply set/reset semantics and write the resulting latch state.
- Parameters:
t β Current solver time.
x β Accepted state vector.
params β Runtime parameter vector.
- Returns:
None
- class VeraGridEngine.Utils.procedural_logic.GradientLimiterLogic(output_var_name: str, source_expr: Expr | Comparison | float | int | bool, lower_rate_expr: Expr | Comparison | float | int | bool, upper_rate_expr: Expr | Comparison | float | int | bool, name: str = '')[source]ο
Bases:
ProceduralLogicBaseClamp the rate of change of one procedural value between lower and upper slopes.
- bind(problem: EmtProblemTemplate) None[source]ο
Bind the logic to a concrete EMT problem.
- Parameters:
problem β EMT problem owning the block and variable maps.
- Returns:
None
- held_valueο
- initializedο
- last_time: float | Noneο
- logic_tpe = 'gradient_limiter'ο
- lower_rate_exprο
- output_idxο
- output_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) GradientLimiterLogic[source]ο
Clone one logic entry under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped procedural logic entry.
- source_exprο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Update mode or event parameters before the Newton step.
- Parameters:
t β Current solver time.
x β Current accepted state.
params β Runtime parameter vector to mutate in place.
- Returns:
None
- upper_rate_exprο
- class VeraGridEngine.Utils.procedural_logic.HardSaturationLogic(output_var_name: str, u_expr: Expr | Comparison, u_min_expr: Expr | Comparison, u_max_expr: Expr | Comparison, name: str = '')[source]ο
Bases:
ProceduralLogicBaseSample one input and apply hard saturation to a runtime mode variable.
- bind(problem: EmtProblemTemplate) None[source]ο
Bind the logic to a concrete EMT problem.
- Parameters:
problem β EMT problem owning the block and variable maps.
- Returns:
None
- logic_tpe = 'hard_saturation'ο
- output_idxο
- output_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) HardSaturationLogic[source]ο
Clone one logic entry under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped procedural logic entry.
- u_exprο
- u_max_exprο
- u_min_exprο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Update mode or event parameters before the Newton step.
- Parameters:
t β Current solver time.
x β Current accepted state.
params β Runtime parameter vector to mutate in place.
- Returns:
None
- class VeraGridEngine.Utils.procedural_logic.MovingAverageLogic(output_var_name: str, source_expr: Expr | Comparison | float | int | bool, delay_expr: Expr | Comparison | float | int | bool, window_expr: Expr | Comparison | float | int | bool, name: str = '')[source]ο
Bases:
ProceduralLogicBaseBuffer-based moving average with optional delay before the averaging window.
- bind(problem: EmtProblemTemplate) None[source]ο
Bind the logic to a concrete EMT problem.
- Parameters:
problem β EMT problem owning the block and variable maps.
- Returns:
None
- delay_exprο
- history: List[Tuple[float, float]]ο
- logic_tpe = 'moving_average'ο
- output_idxο
- output_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) MovingAverageLogic[source]ο
Clone one logic entry under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped procedural logic entry.
- source_exprο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Update mode or event parameters before the Newton step.
- Parameters:
t β Current solver time.
x β Current accepted state.
params β Runtime parameter vector to mutate in place.
- Returns:
None
- window_exprο
- class VeraGridEngine.Utils.procedural_logic.PickupDropoffLogic(output_var_name: str, bool_expr: Expr | Comparison, pickup_delay_expr: Expr | Comparison, drop_delay_expr: Expr | Comparison, name: str = '')[source]ο
Bases:
ProceduralLogicBaseImplement a delayed pickup/dropoff relay with retained binary state.
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the runtime output slot and clear the relay timers.
- Parameters:
problem β Bound EMT problem.
- Returns:
None
- bool_exprο
- drop_delay_exprο
- drop_started_at: float | Noneο
- get_next_forced_event_time(t_prev: float, t_target: float) float | None[source]ο
Return the next exact pickup or dropoff event inside one step.
- Parameters:
t_prev β Previous solver time.
t_target β Nominal target time.
- Returns:
First pending relay event in the interval, if any.
- initializedο
- logic_tpe = 'pickup_dropoff'ο
- output_idxο
- output_var_nameο
- pending_drop_time: float | Noneο
- pending_pickup_time: float | Noneο
- pickup_delay_exprο
- pickup_started_at: float | Noneο
- remap(var_mapping: Dict[Expr | str, Expr]) PickupDropoffLogic[source]ο
Clone the logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped pickup/dropoff logic.
- stateο
- class VeraGridEngine.Utils.procedural_logic.ProceduralLogicBase(name: str = '')[source]ο
Bases:
objectBase class for procedural logic objects attached to symbolic blocks.
Procedural logic is evaluated outside the compiled residual kernels and is intended to drive runtime modes, retained flags, timers, or event scheduling in a structured way.
- bind(problem: EmtProblemTemplate) None[source]ο
Bind the logic to a concrete EMT problem.
- Parameters:
problem β EMT problem owning the block and variable maps.
- Returns:
None
- get_next_forced_event_time(t_prev: float, t_target: float) float | None[source]ο
Return the next exact event time inside the interval if known.
- Parameters:
t_prev β Previous solver time.
t_target β Nominal target time.
- Returns:
Event time or None.
- logic_tpe = 'base'ο
- nameο
- remap(var_mapping: Dict[Expr | str, Expr]) ProceduralLogicBase[source]ο
Clone one logic entry under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped procedural logic entry.
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Update mode or event parameters before the Newton step.
- Parameters:
t β Current solver time.
x β Current accepted state.
params β Runtime parameter vector to mutate in place.
- Returns:
None
- class VeraGridEngine.Utils.procedural_logic.ResetOnRisingEdgeLogic(target_var_name: str, reset_expr: Expr | Comparison, value_expr: Expr | Comparison, name: str = '')[source]ο
Bases:
ProceduralLogicBaseApply one value reset on the rising edge of a procedural condition.
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve whether the reset target is a state variable or a runtime parameter.
- Parameters:
problem β Bound EMT problem.
- Returns:
None
- initializedο
- last_reset_highο
- logic_tpe = 'reset_on_rising_edge'ο
- remap(var_mapping: Dict[Expr | str, Expr]) ResetOnRisingEdgeLogic[source]ο
Clone the logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped reset logic.
- reset_exprο
- target_param_idxο
- target_state_idxο
- target_var_nameο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Apply the reset value only on the rising edge of the reset condition.
- Parameters:
t β Current solver time.
x β Accepted state vector.
params β Runtime parameter vector.
- Returns:
None
- value_exprο
- class VeraGridEngine.Utils.procedural_logic.SampledValueLogic(output_var_name: str, source_expr: Expr | Comparison, name: str = '')[source]ο
Bases:
ProceduralLogicBaseSample one expression at each accepted step and store it in a runtime mode variable.
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the runtime output slot for this sampled value.
- Parameters:
problem β Bound EMT problem.
- Returns:
None
- logic_tpe = 'sampled_value'ο
- output_idxο
- output_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) SampledValueLogic[source]ο
Clone the logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped sampled-value logic.
- source_exprο
- class VeraGridEngine.Utils.procedural_logic.StartupHandoverLogic(mode_var_name: str, enable_time_var_name: str, name: str = '')[source]ο
Bases:
ProceduralLogicBaseOne-shot startup handover for hybrid EMT converter models.
The logic keeps one retained runtime mode at
0during the averaged-startup interval and flips it to1exactly att_enable. This lets the DAE stay continuous before the handover while still forcing an exact solver split when the switched bridge becomes electrically active.- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the retained mode and enable-time runtime indices.
- Parameters:
problem β Bound EMT problem.
- Returns:
None.
- enable_time_idxο
- enable_time_var_nameο
- get_next_forced_event_time(t_prev: float, t_target: float) float | None[source]ο
Return the exact startup-handover time when it falls inside one solver step.
- Parameters:
t_prev β Previous solver time.
t_target β Nominal target time.
- Returns:
Exact handover time or
None.
- logic_tpe = 'startup_handover'ο
- mode_idxο
- mode_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) StartupHandoverLogic[source]ο
Clone the logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped startup-handover logic.
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Update the retained startup mode from the current solver time.
- Parameters:
t β Current solver time.
x β Accepted state vector.
params β Runtime parameter vector.
- Returns:
None.
- class VeraGridEngine.Utils.procedural_logic.ThreePhaseCarrierPwmLogic(mod_a_var_name: str, mod_b_var_name: str, mod_c_var_name: str, gate_a_mode_var_name: str, gate_b_mode_var_name: str, gate_c_mode_var_name: str, omega_sw_var_name: str, carrier_phase_var_name: str, name: str = '')[source]ο
Bases:
ProceduralLogicBaseRegular-sampled three-phase carrier PWM logic.
The logic samples the modulation references at each carrier half-period, computes the exact gate transitions inside that interval, and stores the gate values as retained runtime modes. The symbolic DAE therefore sees piecewise- constant gate parameters instead of symbolic comparator expressions.
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the variable indices and initialize the first PWM interval.
- Parameters:
problem β Bound EMT problem.
- Returns:
None.
- carrier_phase_idxο
- carrier_phase_var_nameο
- current_gateο
- gate_a_idxο
- gate_a_mode_var_nameο
- gate_b_idxο
- gate_b_mode_var_nameο
- gate_c_idxο
- gate_c_mode_var_nameο
- get_next_forced_event_time(t_prev: float, t_target: float) float | None[source]ο
Return the next PWM gate transition or carrier-boundary event.
- Parameters:
t_prev β Previous solver time.
t_target β Nominal target time.
- Returns:
Earliest event in the interval, if any.
- initializedο
- interval_end_time: float | Noneο
- logic_tpe = 'three_phase_carrier_pwm'ο
- mod_a_idxο
- mod_a_var_nameο
- mod_b_idxο
- mod_b_var_nameο
- mod_c_idxο
- mod_c_var_nameο
- omega_sw_idxο
- omega_sw_var_nameο
- pending_transition_gateο
- pending_transition_timeο
- remap(var_mapping: Dict[Expr | str, Expr]) ThreePhaseCarrierPwmLogic[source]ο
Clone the PWM logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped PWM logic.
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Advance the PWM gate states from the accepted modulation references.
- Parameters:
t β Current solver time.
x β Accepted EMT state vector.
params β Runtime parameter vector.
- Returns:
None.
- class VeraGridEngine.Utils.procedural_logic.TimeDelayLogic(output_var_name: str, source_expr: Expr | Comparison | float | int | bool, delay_expr: Expr | Comparison | float | int | bool, name: str = '')[source]ο
Bases:
ProceduralLogicBaseSample one input and expose its delayed value through a runtime mode variable.
- bind(problem: EmtProblemTemplate) None[source]ο
Bind the logic to a concrete EMT problem.
- Parameters:
problem β EMT problem owning the block and variable maps.
- Returns:
None
- delay_exprο
- history: List[Tuple[float, float]]ο
- logic_tpe = 'time_delay'ο
- output_idxο
- output_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) TimeDelayLogic[source]ο
Clone one logic entry under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped procedural logic entry.
- source_exprο
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Update mode or event parameters before the Newton step.
- Parameters:
t β Current solver time.
x β Current accepted state.
params β Runtime parameter vector to mutate in place.
- Returns:
None
- class VeraGridEngine.Utils.procedural_logic.ValveStateLogic(mode_var_name: str, valve_type_var_name: str, gate_var_name: str, antiparallel_var_name: str, voltage_eps_var_name: str, current_eps_var_name: str, valve_voltage_var_name: str, valve_current_var_name: str, name: str = '')[source]ο
Bases:
ProceduralLogicBaseRetained conduction-state logic for generic EMT valve blocks.
The logic updates a single retained runtime mode that encodes the active path:
+1: forward conduction0: blocked state-1: reverse conduction through the antiparallel path
- antiparallel_idxο
- antiparallel_var_nameο
- bind(problem: EmtProblemTemplate) None[source]ο
Resolve the runtime and algebraic indices required by the valve logic.
- Parameters:
problem β Bound EMT problem.
- Returns:
None.
- current_eps_idxο
- current_eps_var_nameο
- gate_idxο
- gate_var_nameο
- logic_tpe = 'valve_state'ο
- mode_idxο
- mode_var_nameο
- remap(var_mapping: Dict[Expr | str, Expr]) ValveStateLogic[source]ο
Clone the valve logic under a variable remapping.
- Parameters:
var_mapping β Variable substitution map.
- Returns:
Remapped valve logic.
- update(t: float, x: ndarray[tuple[Any, ...], dtype[float64]], params: ndarray[tuple[Any, ...], dtype[float64]]) None[source]ο
Update the retained conduction-path mode from the accepted EMT state.
- Parameters:
t β Current solver time.
x β Accepted EMT state vector.
params β Flat runtime parameter vector.
- Returns:
None.
- valve_current_idxο
- valve_current_var_nameο
- valve_type_idxο
- valve_type_var_nameο
- valve_voltage_idxο
- valve_voltage_var_nameο
- voltage_eps_idxο
- voltage_eps_var_nameο
- VeraGridEngine.Utils.procedural_logic.aflipflop(x: Expr | Comparison, boolset: Expr | Comparison, boolreset: Expr | Comparison, output: Var | str, name: str = '') AnalogFlipFlopLogic[source]ο
Build the procedural equivalent of PowerFactory
aflipflop.- Parameters:
x β Analog expression to store while the internal state is high.
boolset β Set condition.
boolreset β Reset condition.
output β Runtime mode variable receiving the held analog value.
name β Optional logic name.
- Returns:
Analog flip-flop procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.bool_and(*args: Expr | Comparison | float | int) Expr[source]ο
Build the boolean AND of one or more procedural expressions.
- Parameters:
args β Boolean-like expressions encoded as 0/1 values.
- Returns:
Expression equal to 1.0 only when all inputs are true.
- VeraGridEngine.Utils.procedural_logic.bool_eor(left: Expr | Comparison | float | int, right: Expr | Comparison | float | int) Expr[source]ο
Build the exclusive-OR of two procedural expressions.
- Parameters:
left β Left boolean-like expression.
right β Right boolean-like expression.
- Returns:
Expression equal to 1.0 only when exactly one input is true.
- VeraGridEngine.Utils.procedural_logic.bool_nand(*args: Expr | Comparison | float | int) Expr[source]ο
Build the boolean NAND of one or more procedural expressions.
- Parameters:
args β Boolean-like expressions encoded as 0/1 values.
- Returns:
Expression equal to the negated AND of the inputs.
- VeraGridEngine.Utils.procedural_logic.bool_nor(*args: Expr | Comparison | float | int) Expr[source]ο
Build the boolean NOR of one or more procedural expressions.
- Parameters:
args β Boolean-like expressions encoded as 0/1 values.
- Returns:
Expression equal to the negated OR of the inputs.
- VeraGridEngine.Utils.procedural_logic.bool_not(arg: Expr | Comparison | float | int) Expr[source]ο
Build the boolean NOT of one procedural expression.
- Parameters:
arg β Boolean-like expression encoded as 0/1.
- Returns:
Expression equal to 1.0 when the input is false.
- VeraGridEngine.Utils.procedural_logic.bool_or(*args: Expr | Comparison | float | int) Expr[source]ο
Build the boolean OR of one or more procedural expressions.
- Parameters:
args β Boolean-like expressions encoded as 0/1 values.
- Returns:
Expression equal to 1.0 when at least one input is true.
- VeraGridEngine.Utils.procedural_logic.build_boundary_updater_from_block(problem: EmtProblemTemplate) BlockProceduralLogicUpdater | None[source]ο
Build a boundary updater from the full procedural logic attached to
problem.sys_block.- Parameters:
problem β EMT problem containing the root block.
- Returns:
Boundary updater or None.
- VeraGridEngine.Utils.procedural_logic.build_procedural_logic_entry(data: Dict[str, Any]) ProceduralLogicBase[source]ο
Deserialize one procedural logic entry.
- Parameters:
data β Serialized logic config.
- Returns:
Procedural logic object.
- VeraGridEngine.Utils.procedural_logic.clone_procedural_logic_entries(entries: List[ProceduralLogicBase], var_mapping: Dict[Expr | str, Expr]) List[ProceduralLogicBase][source]ο
Clone procedural logic entries under a variable remapping.
- Parameters:
entries β Source procedural logic entries.
var_mapping β Mapping from old variables/names to remapped expressions.
- Returns:
Remapped procedural logic entries.
- VeraGridEngine.Utils.procedural_logic.delay(input_expr: Expr | Comparison | float | int | bool, T: Expr | Comparison | float | int | bool, output: Var | str, name: str = '') TimeDelayLogic[source]ο
Build the procedural equivalent of PowerFactory
delay.- Parameters:
input_expr β Source expression to be delayed.
T β Delay in seconds.
output β Runtime mode variable receiving the delayed value.
name β Optional logic name.
- Returns:
Time-delay procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.fixed_sample(output: Var | str, when: Expr | Comparison, name: str = '') FixedSampleLogic[source]ο
Build a fixed-sample selector that stores a boolean condition at initialization.
- Parameters:
output β Runtime mode variable receiving the retained value.
when β Condition sampled at initialization time.
name β Optional logic name.
- Returns:
Fixed-sample procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.flipflop(boolset: Expr | Comparison, boolreset: Expr | Comparison, output: Var | str, name: str = '') FlipFlopLogic[source]ο
Build the procedural equivalent of PowerFactory
flipflop.- Parameters:
boolset β Set condition.
boolreset β Reset condition.
output β Runtime mode variable storing the logical state.
name β Optional logic name.
- Returns:
Flip-flop procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.gradlim_const(input_expr: Expr | Comparison | float | int | bool, gradmin: Expr | Comparison | float | int | bool, gradmax: Expr | Comparison | float | int | bool, output: Var | str, name: str = '') GradientLimiterLogic[source]ο
Build the procedural equivalent of PowerFactory
gradlim_const.- Parameters:
input_expr β Source expression to be rate-limited.
gradmin β Lower slope limit.
gradmax β Upper slope limit.
output β Runtime mode variable receiving the limited value.
name β Optional logic name.
- Returns:
Gradient-limiter procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.hard_saturation(output: Var | str, u: Expr | Comparison, u_min: Expr | Comparison, u_max: Expr | Comparison, name: str = '') HardSaturationLogic[source]ο
Build one procedural hard-saturation entry updated outside Newton residuals.
- Parameters:
output β Runtime mode variable receiving saturated value.
u β Unsaturated input expression.
u_min β Lower saturation bound.
u_max β Upper saturation bound.
name β Optional logic name.
- Returns:
Hard-saturation procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.ifelse(boolexpr: Expr | Comparison | float | int, when_true: Expr | Comparison | float | int, when_false: Expr | Comparison | float | int) Expr[source]ο
Reject equation-level ifelse usage in the public procedural API.
- Parameters:
boolexpr β Switching condition.
when_true β Value chosen for the true branch.
when_false β Value chosen for the false branch.
- Returns:
Never returns because public equation-level selection is blocked.
- VeraGridEngine.Utils.procedural_logic.lastvalue(input_expr: Expr | Comparison, output: Var | str, name: str = '') SampledValueLogic[source]ο
Build the procedural equivalent of PowerFactory
lastvalue.- Parameters:
input_expr β Source expression to be sampled.
output β Runtime mode variable receiving the sampled value.
name β Optional logic name.
- Returns:
Sampled-value procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.movingavg(input_expr: Expr | Comparison | float | int | bool, Tdel: Expr | Comparison | float | int | bool, Tlength: Expr | Comparison | float | int | bool, output: Var | str, name: str = '') MovingAverageLogic[source]ο
Build the procedural equivalent of PowerFactory
movingavg.- Parameters:
input_expr β Source expression to be averaged.
Tdel β Delay before the averaging window.
Tlength β Averaging window length in seconds.
output β Runtime mode variable receiving the averaged value.
name β Optional logic name.
- Returns:
Moving-average procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.picdro(boolexpr: Expr | Comparison, Tpick: Expr | Comparison, Tdrop: Expr | Comparison, output: Var | str, name: str = '') PickupDropoffLogic[source]ο
Build the procedural equivalent of PowerFactory
picdro.- Parameters:
boolexpr β Relay driving condition.
Tpick β Pickup delay.
Tdrop β Dropoff delay.
output β Runtime mode variable storing the relay state.
name β Optional logic name.
- Returns:
Pickup/dropoff procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.picdro_const(boolexpr: Expr | Comparison, Tpick: Expr | Comparison, Tdrop: Expr | Comparison, output: Var | str, name: str = '') PickupDropoffLogic[source]ο
Build the procedural equivalent of PowerFactory
picdro_const.- Parameters:
boolexpr β Relay driving condition.
Tpick β Pickup delay.
Tdrop β Dropoff delay.
output β Runtime mode variable storing the relay state.
name β Optional logic name.
- Returns:
Pickup/dropoff procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.pickup_dropoff(output: Var | str, boolexpr: Expr | Comparison, Tpick: Expr | Comparison, Tdrop: Expr | Comparison, name: str = '') PickupDropoffLogic[source]ο
Build a pickup/dropoff relay-style procedural logic entry.
- Parameters:
output β Runtime mode variable storing the relay state.
boolexpr β Pickup/reset driving condition.
Tpick β Pickup delay.
Tdrop β Dropoff delay.
name β Optional logic name.
- Returns:
Pickup/dropoff procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.procedural_logic_entry_to_dict(entry: ProceduralLogicBase) Dict[str, Any][source]ο
Serialize one procedural logic entry.
- Parameters:
entry β Procedural logic entry.
- Returns:
Serialized logic dictionary.
- VeraGridEngine.Utils.procedural_logic.procedural_logic_from_dict(entries: List[Dict[str, Any]]) List[ProceduralLogicBase][source]ο
Deserialize a list of procedural logic entries.
- Parameters:
entries β Serialized entries.
- Returns:
Procedural logic objects.
- VeraGridEngine.Utils.procedural_logic.procedural_logic_to_dict(entries: List[ProceduralLogicBase]) List[Dict[str, Any]][source]ο
Serialize a list of procedural logic entries.
- Parameters:
entries β Logic entries.
- Returns:
Serialized representation.
- VeraGridEngine.Utils.procedural_logic.reset(var: Var | str, rst: Expr | Comparison, val: Expr | Comparison, name: str = '') ResetOnRisingEdgeLogic[source]ο
Build the procedural equivalent of PowerFactory
reset.- Parameters:
var β Target runtime/state variable name.
rst β Reset trigger condition.
val β Value applied on the rising edge.
name β Optional logic name.
- Returns:
Reset-on-rising-edge procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.sampled_value(output: Var | str, source: Expr | Comparison, name: str = '') SampledValueLogic[source]ο
Build a sampled runtime value updated outside the Newton residual.
- Parameters:
output β Runtime mode variable receiving the sampled value.
source β Source expression to be evaluated at the accepted sample time.
name β Optional logic name.
- Returns:
Sampled-value procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.select(boolexpr: Expr | Comparison | float | int, when_true: Expr | Comparison | float | int, when_false: Expr | Comparison | float | int) Expr[source]ο
Reject equation-level select usage in the public procedural API.
- Parameters:
boolexpr β Switching condition.
when_true β Value chosen for the true branch.
when_false β Value chosen for the false branch.
- Returns:
Never returns because public equation-level selection is blocked.
- VeraGridEngine.Utils.procedural_logic.selfix(boolexpr: Expr | Comparison, output: Var | str, name: str = '') FixedSampleLogic[source]ο
Build the procedural equivalent of PowerFactory
selfix.- Parameters:
boolexpr β Condition sampled at initialization time.
output β Runtime mode variable receiving the retained value.
name β Optional logic name.
- Returns:
Fixed-sample procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.selfix_const(boolexpr: Expr | Comparison, output: Var | str, name: str = '') FixedSampleLogic[source]ο
Build the procedural equivalent of PowerFactory
selfix_const.- Parameters:
boolexpr β Condition sampled at initialization time.
output β Runtime mode variable receiving the retained value.
name β Optional logic name.
- Returns:
Fixed-sample procedural logic entry.
- VeraGridEngine.Utils.procedural_logic.startup_handover(mode: Var | str, t_enable: Var | str, name: str = '') StartupHandoverLogic[source]ο
Build one exact-time startup-handover logic entry.
- Parameters:
mode β Retained mode variable that becomes
1after the handover time.t_enable β Runtime parameter storing the switching-enable time.
name β Optional logic name.
- Returns:
Startup-handover procedural logic entry.
VeraGridEngine.Utils.progress_bar moduleο
- VeraGridEngine.Utils.progress_bar.print_progress_bar(iteration: int, total: int, length=40, txt='')[source]ο
Simple text progress bar :param iteration: current iteration (1 based) :param total: total progress :param length: length of the bar in characters :param txt: text to print at the end of the progress bar
VeraGridEngine.Utils.rms_models_types moduleο
- VeraGridEngine.Utils.rms_models_types.build_equivalence_classes_dict(grid: MultiCircuit) Tuple[Dict[int, List[int]], Dict[int, List[List[int]]], Dict[int, List[int]]][source]ο
this functions receives the grid and return a dictionary with clases of equivalence of the dynamic models and a dictionary with clases of equivalence of their variables. :param grid: :type grid: :return: Tuple of:
Dict with new uid as keys and lists of equivalent block uids as values
Dict with representative uid as keys and lists of lists of equivalent variable uids as values
Dict with representative uid as keys and lists of all block uids composing that model (including children)
- Return type:
VeraGridEngine.Utils.scores moduleο
- class VeraGridEngine.Utils.scores.TechnoEconomicScores[source]ο
Bases:
objectInvestmentScores
- arr() ndarray[tuple[Any, ...], dtype[float64]][source]ο
Return multidimensional metrics for the optimization :return: array of 2 values
- capex_score: floatο
- property financial_score: floatο
Get the financial score: CAPEX + OPEX :return: float
- losses_score: floatο
- opex_score: floatο
- overload_score: floatο
- property tech_scoreο
- voltage_angle_score: floatο
- voltage_module_score: floatο
- VeraGridEngine.Utils.scores.get_overload_score(loading: ndarray[tuple[Any, ...], dtype[complex128]], branches_cost: ndarray[tuple[Any, ...], dtype[float64]], threshold=1.0) float[source]ο
Compute overload score by multiplying the loadings above 100% by the associated branch cost. :param loading: load results :param branches_cost: all branch elements from studied grid :param threshold: threshold for overload :return: sum of all costs associated to branch overloads
- VeraGridEngine.Utils.scores.get_voltage_module_score(voltage: ndarray[tuple[Any, ...], dtype[complex128]], vm_cost: ndarray[tuple[Any, ...], dtype[float64]], vm_max: ndarray[tuple[Any, ...], dtype[float64]], vm_min: ndarray[tuple[Any, ...], dtype[float64]]) float[source]ο
Compute voltage module score by multiplying the voltages outside limits by the associated bus costs. :param voltage: voltage results :param vm_cost: Vm cost array :param vm_max: maximum voltage :param vm_min: minimum voltage :return: sum of all costs associated to voltage module deviation
- VeraGridEngine.Utils.scores.get_voltage_phase_score(voltage: ndarray[tuple[Any, ...], dtype[complex128]], va_cost: ndarray[tuple[Any, ...], dtype[float64]], va_max: ndarray[tuple[Any, ...], dtype[float64]], va_min: ndarray[tuple[Any, ...], dtype[float64]]) float[source]ο
Compute voltage phase score by multiplying the phases outside limits by the associated bus costs. :param voltage: voltage results :param va_cost: array of bus angles costs :param va_max: maximum voltage angles :param va_min: minimum voltage angles :return: sum of all costs associated to voltage module deviation