def __createVector(self, name: str, objecttype, startindex: int, endindex: int) -> Vector: v = Vector(name, objecttype, startindex, endindex) self.vectors[name] = v self.typeMap[name] = VariableTypes.FLUID return v
def process_unary_operation(self, term, operator): result = [] interaction = None for element in term: if isinstance(element, Interaction): interaction = self.currentmodule.add_finteraction_custom_interaction( element, operator, InteractionType.TECHNOLOGY_PROCESS) else: interaction = self.currentmodule.add_fluid_custom_interaction( element, operator, InteractionType.TECHNOLOGY_PROCESS) result.append(interaction) v = Vector.create_from_list_things(operator, result) ret = v.get_range() return ret
def __createLiteralVector(self, name: str, values: List) -> Vector: objectype = None if isinstance(values, list): objectype = type(values[0]) else: objectype = type(values) values = [values] v = Vector.create_from_list_things(name, values) self.vectors[name] = v self.typeMap[name] = VariableTypes.NUMBER return v
def __evaluate_fluid_numeric_operator(self, operand_fluidic: VectorRange, operand_numeric: float, operator: str) -> VectorRange: fluid = operand_fluidic[0] interactions = [] for fluid in operand_fluidic: interaction = None if operator == "*": # TODO: Create interaction/operation node(s) on the FIG interaction = self.currentmodule.add_fluid_numeric_interaction( fluid, operand_numeric, InteractionType.DILUTE) elif operator == "/": # TODO: Create interaction/operation node(s) on the FIG interaction = self.currentmodule.add_fluid_numeric_interaction( fluid, operand_numeric, InteractionType.DIVIDE) elif operator == "%": # TODO: Create interaction/operation node(s) on the FIG interaction = self.currentmodule.add_fluid_numeric_interaction( fluid, operand_numeric, InteractionType.METER) elif operator == "+": raise Exception( "Unsuppored operator on 1:fluidic 2:numeric values: {0}". format(operator)) elif operator == "-": raise Exception( "Unsuppored operator on 1:fluidic 2:numeric values: {0}". format(operator)) else: raise Exception( "Unsuppored operator on 1:fluidic 2:numeric values: {0}". format(operator)) interaction.operator = operator interactions.append(interaction) v = Vector.create_from_list_things("interaction_" + operand_fluidic.id, interactions) result = v.get_range() return result
def __evalute_fluid_fluid_operator(self, operand1, operand2, operator): if len(operand1) is not len(operand2): # TODO - Implement Fluidic operators on non equal # dimensions of the operands raise Exception( "Operand {0} and Operand {1} are of different Dimensions". format(operand1, operand2)) operand1_element = None operand2_element = None interactiontype = None result = [] vecname = operand1.id + "_" + operand2.id # TODO: Find out why the zip give a None item at the end # for operand1_element, operand2_element in zip(operand1, operand2): for i in range(len(operand1)): operand1_element = operand1[i] operand2_element = operand2[i] if operator == '*': raise Exception( "Unsuppored operator on two fluid values: {0}".format( operator)) elif operator == '/': raise Exception( "Unsuppored operator on two fluid values: {0}".format( operator)) elif operator == '%': raise Exception( "Unsuppored operator on two fluid values: {0}".format( operator)) elif operator == '+': # TODO: We need to return the operation node here that is generated by operating on the # two different operators interactiontype = InteractionType.MIX elif operator == '-': # TODO: In case of substraction, we need to return the operand1 back again, # since the subtracted node becomes an output, of whats given to the fluid interactiontype = InteractionType.SIEVE else: raise Exception( "Unsuppored operator on two fluid values: {0}".format( operator)) # TODO: Check if the operation here is between two different fluids or a fluid and an fluidinteraction if isinstance(operand1_element, Interaction) and isinstance( operand2_element, Interaction): result_element = self.currentmodule.add_finteraction_finteraction_interaction( operand1_element, operand2_element, interactiontype) elif isinstance(operand1_element, Interaction): result_element = self.currentmodule.add_fluid_finteraction_interaction( operand2_element, operand1_element, interactiontype) elif isinstance(operand2_element, Interaction): result_element = self.currentmodule.add_fluid_finteraction_interaction( operand1_element, operand2_element, interactiontype) else: result_element = self.currentmodule.add_fluid_fluid_interaction( operand1_element, operand2_element, interactiontype) result.append(result_element) v = Vector.create_from_list_things(vecname, result) return v.get_range()