def test_variable_interfaces(self): from libcellml import Component, Model, Variable m = Model() c1 = Component("c1") c2 = Component("c2") v1 = Variable("v1") v2 = Variable("v2") c1.addVariable(v1) c2.addVariable(v2) m.addComponent(c1) m.addComponent(c2) Variable.addEquivalence(v1, v2) m.fixVariableInterfaces() self.assertEqual("public", v1.interfaceType()) self.assertEqual("public", v2.interfaceType())
# 7.d # Create variable connections between these variables and their counterparts in the equations # components. Validate, expecting errors related to missing or incorrect interface types. Variable.addEquivalence(k_channel_parameters.variable('E_K'), k_channel_equations.variable('E_K')) Variable.addEquivalence(k_channel_parameters.variable('g_K'), k_channel_equations.variable('g_K')) Variable.addEquivalence(n_gate.variable('n'), n_gate_equations.variable('n')) validator.validateModel(model) print_issues(validator) # 7.e # Set the required interface types as listed by the validator. This can be done individually using the # Variable.setInterfaceType() function, or automatically using the Model.fixVariableInterfaces() # function. Validate again, expecting no validation errors. model.fixVariableInterfaces() validator.validateModel(model) print_issues(validator) # end 7.e # If we were to analyse the model again now we would we still have the same set of errors # as earlier as we haven't given a value to any of our parameters. We can use the # Variable.setInitialValue() function to give these values to the following variables # in the parameters components: # - potassium channel parameters: # - E_K = -87 [mV] # - g_K = 36 [milliS_per_cm2] # - n_gate parameters # - n = 0.325 [dimensionless] # 7.f