Engee documentation
Notebook

A coefficient-to-speed converter using command control in cycles

The converter takes the coefficient and converts it to speed.

The mathematical model of the converter is an algebraic equation, where the position range K = 0 to 1 corresponds
to the speed range v = from 45 to 95 km/h.
The total speed is
v = 50x + 45, the figure below shows the implemented model itself.

image.png

Next, we will connect the auxiliary function for launching the model and declare the initial states for it.

In [ ]:
function run_model( name_model)
    
    Path = (@__DIR__) * "/" * name_model * ".engee"
    
    if name_model in [m.name for m in engee.get_all_models()] # Checking the condition for loading a model into the kernel
        model = engee.open( name_model ) # Open the model
        model_output = engee.run( model, verbose=true ); # Launch the model
    else
        model = engee.load( Path, force=true ) # Upload a model
        model_output = engee.run( model, verbose=true ); # Launch the model
        engee.close( name_model, force=true ); # Close the model
    end
    sleep(5)
    return model_output
end
Out[0]:
run_model (generic function with 1 method)

The starting conditions will be set as follows:

In [ ]:
K_arr = 0:0.2:1;

Let's run the model in a loop changing the value of r.

In [ ]:
v = zeros(size(K_arr,1),1)
K = 0.0;
for i in 1:size(K_arr,1)  
    K = K_arr[i]
    run_model("setspeed") # Launching the model.
    V = collect(simout["setspeed/V"]);
    v[i,:] = V.value
end 
Building...
Progress 100%
Building...
Progress 100%
Building...
Progress 100%
Building...
Progress 100%
Building...
Progress 100%
Building...
Progress 100%

Let's display and compare the results obtained, and plot the final speed and input coefficients.

In [ ]:
plot(K_arr,v)
Out[0]:

Conclusion

Based on the results of the model execution, we see that as the coefficient increases, the speed increases accordingly.

Blocks used in example