Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Dymola - Independent variables

Dymola - Independent variables

Hi modelers,

I'm facing a problem when i want to plot two simulation results against a reference variable:

Let's say that i've got 2 instantiations of the same model. The model describe a translating mass, driving by a motor. The difference between them are the parameter's values and in each model.

I would like to plot the motor torque against the mass-posistion. The problem is that, the Mass-position is function of the respective "model time" or "model integration step" (actually i don't know). Which means that :
- if one mass is faster than the other and if i plot the both torque variables against position( from Mass1 or Mass2) i will not have the same plot-result.

But, the path is the same for the both mass, so why isn't it an absolut reference for the both model?! What should i do to cancel this effect, any help will be really appreciate.

------------
if i summarize :

i have :
Torque_motor1=Function(Position_Mass1)
Torque_motor2=Function(Position_Mass1)
or
Torque_motor1=Function(Position_Mass2)
Torque_motor2=Function(Position_Mass2)

i want :

Torque_motor1=Function(Position)
Torque_motor2=Function(Position)

thanks

Re: Dymola - Independent variables

well, i might be not clear enough.
Here is a script that i wrote to handle this problem, but i would like to plug that directly in the model and not in a script


Code:


n=readTrajectorySize("dsres.mat"); // find the length of the simulation results vectors
traj_mass1=transpose(readTrajectory("dsres.mat",{"massWithStopAndFriction.s"},n));  //extract the mass one trajectory
traj_mass2=transpose(readTrajectory("dsres.mat",{"massWithStopAndFriction1.s"},n)); //extract the mass two trajectory
traj_Vmass1=transpose(readTrajectory("dsres.mat",{"massWithStopAndFriction.der(s)"},n)); //transpose tranformation
traj_Vmass2=transpose(readTrajectory("dsres.mat",{"massWithStopAndFriction1.der(s)"},n)); //transpose tranformation

// creation of a vector of 500 points
pos=fill(0,500,1);

//creation of a [500,3] matrix
vitessFpos=fill(0,500,3);

// I want to have a point pro millimeter (the masses move from 0 to 0.5m)
pos[:,1]=1:500;
pos[:,1]=0.001*pos[:,1];

//loop to find the index in trajectory mass vector where the mass  step from 1 mm
indexref=fill(0,500,2);
for i in 1:500 loop
    for j in 1:n loop
   
        if traj_mass1[j,1]-pos[i,1]<=0.0001 then
            indexref[i,1]=j;
        else
        end if;
        if traj_mass2[j,1]-pos[i,1]<=0.0001 then
            indexref[i,2]=j;
        else
        end if;
    end for;
end for;

vitessFpos[:,1]=pos[:,1]; //copy the first column of the position vector (it's the reference position vecotr)

// loop to find the velocity value in the velocity vector the point where we step from one millimeter to an other

for i in 1:500 loop

    vitessFpos[i,2]=traj_Vmass1[indexref[i,1],1];
    vitessFpos[i,3]=traj_Vmass2[indexref[i,2],1];
end for;

plotArrays(vitessFpos[:,1], vitessFpos[:,2:3]); // plot the result Velocities of the both masses against the absolut position

There are 0 guests and 0 other users also viewing this topic
You are here: