BODE PLOT from COSELICA DIAGRAM

Hello everybody,

My question is very simple : is it possible to draw a bode plot from a COSELICA DIAGRAM?

I have created a diagram with COSELICA in SCILAB 2024.1.0

This diagram is working fine but now I wanted to get the corresponding bode plot. Is it possible?

The diagram:
RC circuit fait avec COSELICA 2024.0.0

The temporal simulation curve:
RC circuit made with COSELICA 2024.0.0 blocks

I should point out that I’ve already successfully used the post_xcos_simulate function in a scilab script to plot the bode curves of an XCOS schematic containing a transfer function block.
Here, I’m stuck because there’s no transfer function.

I give below the detail of such a script (this one is designed to search for CLR blocks):

//This module plots the Bode curves of an XCOS diagram with a transfer function
//
//We load the XCOS file to simulate
importXcosDiagram("C:\Users\file_name.zcos")

// Clear any pre_xcos_simulation
clear pre_xcos_simulate;

//Get data from the XCOS diagram (CLR block is the transfer function block)
function post_xcos_simulate(%cpr, scs_m, needcompile)
    // Retrieve all objects
    objs = scs_m.objs;

    clrBlock = [];
    //Looking for CLR block
    for i=1:size(objs)
        if objs(i).gui == "CLR" then
            clrBlock = objs(i);
            break;
        end
    end


    // Retrieve exprs
    s = poly(0,'s');
    expr = clrBlock.graphics.exprs;
    num = evstr(expr(1));
    den = evstr(expr(2));
    h = syslin('c', num/den);
    // Open new figure then plot Bode
    scf(max(winsid())+1);
    bode(h, 0.01, 100,"Mon filtre");
endfunction

//Launching the Bode plot
xcos_simulate(scs_m, 4);

How to modify this script to fit with my purpose?

Hello,

you don’t even have a well-defined input, do you ? First, the logic of Modelica blocks is completely different from a CLR block, as the former are non-causal blocks, i.e. input and/or output do not make sense.
In order to plot a Bode diagram you need a transfer function (a rational Scilab object, which can be extracted from a CLR block) or a linear time invariant state-space representation (A,B,C,D). There is even no such mapping between an arbitrary Xcos block or superblock (which can be nonlinear and non stationary, hence no transfer function makes sense), so this is even worse with an arbitrary superblock made of Modelica blocks.

S.

OK thank you, I thought it was mission impossible.
But I asked because I saw that was possible in OpenModelica and in Dymola.