[MBDyn-users] Socket problems

Richard Crozier r.crozier at ed.ac.uk
Wed Oct 19 12:43:23 CEST 2016


Apologies for sending many emails (it doesn't mean I expect immediate 
responses, just reporting things as I find them).

To follow up on my previous emails, I still have trouble with the 
sockets. With the attached files I get the expected output if I do not 
use socket forces, but a memory error if I attempt to use sockets. To 
use socket forces, run the attached shell script which uses 
test_strext_socket to supply the forces). For me this gives the output:

-----------------
*** Starting MBDyn... PID=23954; sleeping 2 seconds...
*** Starting test...
iterations: 3
cmd to peer: 7 (NEGOTIATION)
cmd from peer: 8 (OK)
cmd from peer: 2 (REGULAR_DATA)
node #0 (2):
     x=      +0.00000000e+00  +0.00000000e+00  +0.00000000e+00
     R=      +1.00000000e+00  +0.00000000e+00  +0.00000000e+00
             +0.00000000e+00  +1.00000000e+00  +0.00000000e+00
             +0.00000000e+00  +0.00000000e+00  +1.00000000e+00
     xp=     +0.00000000e+00  +0.00000000e+00  +0.00000000e+00
     omega=  +0.00000000e+00  +0.00000000e+00  +0.00000000e+00
cmd to peer: 2 (REGULAR_DATA)
unknown cmd (0) from peer
*** Error in 
`/home/rcrozier/src/mbdyn-1.7.1/utils/.libs/lt-test_strext_socket': 
double free or corruption (out): 0x0000000000a7a050 ***
Aborted
*** Done
-----------------

Alternatively, if I supply the -n argument to test_strext_socket, I do 
not get this error, but instead, I get an error about a mismatch in the 
orientation output (but it is specified in the file as 'orientation 
matrix', and in the call to test_strext_socket as '-R mat').

-----------------
[solver.cc,551]: creating solution vectors
StructExtForce(3001): negotiation response failed: orientation output 
mismatch (local=512, remote=0)
-----------------

I've also tried using theta (and 'orientation vector' in the mbd file) 
and euler123, in all cases the 'local' value changed, but remote remains 
zero.

Finally, if I comment out the socket forces (i.e. comment line 43 and 
lines 220 to 236) then launch mbdyn as normal:

mbdyn -f heaving_buoy_socket_forces.mbd

The problem is solved as normal with no error.

I don't understand why the other examples (springmass and socket) work 
fine and this one does not, but also don't see any error in how I have 
set up the file, especially as it runs fine without the socket forces.

Regards,

Richard

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

-------------- next part --------------
# heaving buoy test

begin: data;
    problem: initial value; # the default
end: data;

begin: initial value;
    initial time: 0.;
    final time: 10.;
    time step: 1.e-2;

    max iterations: 10;
    tolerance: 1.e-6;

    derivatives coefficient: 1e-9;
    derivatives tolerance: 1e-6;
    derivatives max iterations: 10;
    
    output: iterations, residual, solution, counter, bailout;

end: initial value;

begin: control data;
    
    structural nodes: 
        +1    # node in the buoy
        +1    # node in the translator
        +1    # node in the stator
    ;
    rigid bodies:
        +1    # node in the buoy
        +1    # node in the translator
        +1    # node in the stator
    ;
    joints:
        +1    # stator to translator: prismatic
        +1    # stator to translator: in line
        +1    # stator to ground: revolute pin
        +1    # translator to buoy: total joint
    ;
    forces:
        +1    # buoyancy
        +1    # socket
    ;
    gravity;
    
end: control data;

set: integer nd_translator_id = 1;
set: integer nd_buoy_id = 2;
set: integer nd_stator_id = 3;

set: integer bd_stator_id = 1000+nd_stator_id;
set: integer bd_translator_id = 1000+nd_translator_id;
set: integer bd_buoy_id = 1000+nd_buoy_id;

set: real stator_d = 600e-3;
set: real stator_l = 1.0;
set: real stator_mass = pi * (stator_d/2.0)^2.0 * stator_l * 7500;

#set: real base_d = 2.0 * stator_d;
#set: real base_l = 0.5 * stator_l;
#set: real base_mass = stator_mass;

set: real translator_d = 300e-3;
set: real translator_l = 8.0;
set: real translator_mass = pi * (translator_d/2.0)^2.0 * translator_l * 100.0;

# 2m diameter buoy
set: real draft = 1.0;
set: real buoy_l = 3.0;
set: real buoy_d = 2.0;
set: real rho_water = 1025.0;
set: real displaced_mass = ( pi * (buoy_d/2.0)^2.0 * draft * rho_water);
set: real buoy_mass = displaced_mass - translator_mass;
set: real initial_heave_position = 0.25;

set: integer ref_stator = 4001;
set: integer ref_translator = 4002;
set: integer ref_buoy = 4003;

reference: ref_buoy,
    reference, global, null,
    reference, global, eye,
    reference, global, null,
    reference, global, null;

reference: ref_stator,
    reference, ref_buoy, 0.0, 0.0, -(translator_l/2.0) - (buoy_l/2.0),
    reference, ref_buoy, eye,
    reference, ref_buoy, null,
    reference, ref_buoy, 0.0, 0.0, 0.0;

reference: ref_translator,
    reference, ref_stator, null,
    reference, ref_stator, eye,
    reference, ref_stator, null,
    reference, ref_stator, null;


begin: nodes;
    structural: nd_stator_id, dynamic, 
        reference, ref_stator, null,  # relative position
        reference, ref_stator, eye,   # relative orientation
        reference, ref_stator, null,  # relative velocity
        reference, ref_stator, null;  # relative angular velocity

    structural: nd_translator_id, dynamic,
        reference, ref_translator, null,
        reference, ref_translator, eye,
        reference, ref_translator, null,
        reference, ref_translator, null;
    
    structural: nd_buoy_id, dynamic, 
        reference, ref_buoy, null,
        reference, ref_buoy, eye,
        reference, ref_buoy, null,
        reference, ref_buoy, null;

end: nodes;

set: real buoy_Ixx = buoy_mass * (3.*buoy_d^2+buoy_l^2)/12.;
set: real buoy_Iyy = buoy_mass * (3.*buoy_d^2+buoy_l^2)/12.;
set: real buoy_Izz = buoy_mass * (buoy_d + buoy_d)^2/8.0;

set: real translator_Ixx = translator_mass * (3.*translator_d^2+translator_l^2)/12.;
set: real translator_Iyy = translator_mass * (3.*translator_d^2+translator_l^2)/12.;
set: real translator_Izz = translator_mass * (translator_d + translator_d)^2/8.0;

set: real stator_Ixx = stator_mass * (3.*stator_d^2+stator_l^2)/12.;
set: real stator_Iyy = stator_mass * (3.*stator_d^2+stator_l^2)/12.;
set: real stator_Izz = stator_mass * (stator_d + stator_d)^2/8.0;

begin: elements;

    body: bd_buoy_id, nd_buoy_id,
      buoy_mass,                        # mass
      null,                             # relative center of mass
      diag, buoy_Ixx, buoy_Iyy, buoy_Izz; # inertia matrix
      
    body: bd_translator_id, nd_translator_id,
      translator_mass,                  # mass
      null,                             # relative center of mass
      diag, translator_Ixx, translator_Iyy, translator_Izz; # inertia matrix

    body: bd_stator_id, nd_stator_id,
      stator_mass,                      # mass
      null,                             # relative center of mass
      diag, stator_Ixx, stator_Iyy, stator_Izz; # inertia matrix

    # joint ids
    set: integer jo_statorHinge_id = 2000;
    set: integer jo_buoyTransClamp_id = 2001;
    set: integer jo_statorTransP_id = 2002;
    set: integer jo_statorTransInLine_id = 2003;

    # create a hinge at the midle of the stator so it can pitch
    joint: jo_statorHinge_id, revolute pin,
        nd_stator_id, 
            reference, ref_stator, null,          # relative offset
            hinge, reference, ref_stator,           # relative axis orientation
                1, 1.,0.,0., 3, 0.,1.,0.,
            reference, ref_stator, null,          # absolute pin position
            hinge, reference, ref_stator,           # absolute pin orientation
                1, 1.,0.,0., 3, 0.,1.,0.;

    # clamp the buoy to the translator using a total joint to 
    # restrain all the degrees of freedom between the nodes
    joint: jo_buoyTransClamp_id, total joint,
        nd_translator_id,
            position, 
                reference, ref_translator, 0., 0., translator_l/2.0,
            position orientation, 
                reference, ref_translator, eye,
            rotation orientation, 
                reference, ref_translator, eye,
        nd_buoy_id,
        position, 
                reference, ref_buoy, 0., 0., -buoy_l/2.0,
            position orientation, 
                reference, ref_buoy, eye,
            rotation orientation, 
                reference, ref_buoy, eye,
        position constraint,
            active,            
            active,            
            active,
            null,
        orientation constraint,
            active,        
            active,         
            active,
            null;

    joint: jo_statorTransP_id, prismatic,
        nd_stator_id, 
        nd_translator_id;

    joint: jo_statorTransInLine_id, in line,
        nd_stator_id,
        reference, ref_translator, null,    # relative line position
        1, 1., 0., 0., 3, 0., 0., 1.,        # relative orientation (dir 3 is direction)
        nd_translator_id;


    set: integer fc_buoyancy_id = 3000;
    set: integer fc_buoy_ext_id = 3001;
    set: real buoyancyPerH = rho_water * 9.81 * pi * (buoy_d/2.0)^2.0;
    #set: real offset_force = buoyancyPerH*(translator_l/2.0 + buoy_l/2.0 + draft - initial_heave_position);
    set: real offset_force = 0.0;

    force: fc_buoyancy_id,
        absolute,
           nd_buoy_id,
              position, null,              # relative arm
              0., 0., 1.0,
              dof, nd_buoy_id, structural, 3,  
                 algebraic, linear, offset_force, -buoyancyPerH; # buoyancy is based on z position of buoy

    # buoy force from external program, matlab in our case
    force: fc_buoy_ext_id, external structural,
        socket,                 # socket communicator
          create,
              yes,
          path,
              "/tmp/mbdyn.sock",
          no signal,
        coupling,
            tight,
            #loose,
        labels, 
            yes,
        orientation,
            orientation matrix,
        #    orientation vector,
        #    euler123,
        1,                      # number of nodes to receive forces
            nd_buoy_id, offset, null,      # buoy
        echo, "heaving_buoy_socket_forces_config.txt";

    gravity: 0., 0., -1., const, 9.81;
    
    print symbol table;

end: elements;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: heaving_buoy_socket_forces.sh
Type: application/x-shellscript
Size: 2143 bytes
Desc: not available
URL: <http://mail.mbdyn.org/pipermail/mbdyn-users/attachments/20161019/a3f69cad/attachment.bin>


More information about the MBDyn-users mailing list