02.04.2013 Views

Welcome to Adams/Solver Subroutines - Kxcad.net

Welcome to Adams/Solver Subroutines - Kxcad.net

Welcome to Adams/Solver Subroutines - Kxcad.net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

114<br />

<strong>Adams</strong>/<strong>Solver</strong><br />

DOUBLE PRECISION DX, VZ<br />

INTEGER NUM, IPAR(2)<br />

LOGICAL ERRFLG<br />

LOGICAL PARFLG<br />

CALL ADAMS_NEEDS_PARTIALS(PARFLG)<br />

IPAR(1) = PAR(1)<br />

IPAR(2) = PAR(2)<br />

CALL SYSFNC('DX', IPAR, 2, DX, ERRFLG )<br />

CALL SYSFNC('VZ', IPAR, 2, VZ, ERRFLG )<br />

VALUE = DX*VZ<br />

IF(PARFLG) THEN<br />

CALL SYSPAR('DX', IPAR, 2, VZ, 1, ERRFLG)<br />

CALL SYSPAR('VZ', IPAR, 2, DX, 1, ERRFLG)<br />

ENDIF<br />

CALL ERRMES(ERRFLG,'ERROR FOR SFORCE ',ID,'STOP')<br />

RETURN<br />

END<br />

Using SYSPAR with Utility <strong>Subroutines</strong><br />

This SFOSUB example shows how you can use SYSPAR in conjunction with utility subroutines. In this<br />

SFOSUB you have:<br />

VALUE = -IMPACT(400-DM(12,9),-VR(12,9))<br />

or, using the nomenclature developed earlier:<br />

F = -IMPACT(400-M 1 ,-M 2 )<br />

where M 1 = DM(12,9) and M 2 = VR(12,9). Here, you must rely on the ability of the IMPACT utility<br />

function <strong>to</strong> provide partial derivatives of its arguments.<br />

∂ F<br />

----------<br />

∂ M1 ∂ F<br />

----------<br />

∂ M2 =<br />

=<br />

∂ IMPACT<br />

-------------------------- ( 400 – M<br />

∂ M 1′ – M2) ( – 1)<br />

1<br />

∂ IMPACT<br />

-------------------------- ( 400 – M<br />

∂ M 1′ – M2) ( – 1)<br />

2<br />

The implementation follows. Pay close attention <strong>to</strong> the use of the IORD argument (argument 8) <strong>to</strong> the<br />

IMPACT function. It controls whether 0th, 1st, or 2nd derivative of the impact is being requested. Learn<br />

more about the IMPACT function (C++ or FORTRAN).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!