added ASMT api example runSinglePendulum

This commit is contained in:
Aik-Siong Koh
2023-09-28 15:51:02 -06:00
parent 81513500ab
commit b53cdac5ca
37 changed files with 845 additions and 128 deletions

View File

@@ -19,7 +19,7 @@
#include "ASMTRotationalMotion.h"
#include "ASMTTranslationalMotion.h"
#include "ASMTMarker.h"
#include "Part.h"
#include "ASMTPart.h"
#include "ASMTTranslationalJoint.h"
#include "ASMTSphericalJoint.h"
#include "ASMTFixedJoint.h"
@@ -27,10 +27,151 @@
#include "ASMTUniversalJoint.h"
#include "ExternalSystem.h"
#include "ASMTPointInPlaneJoint.h"
#include "ASMTPrincipalMassMarker.h"
#include "ASMTForceTorque.h"
#include "ASMTConstantGravity.h"
#include "ASMTSimulationParameters.h"
#include "ASMTAnimationParameters.h"
#include "Part.h"
#include "ASMTRefPoint.h"
#include "ASMTRefCurve.h"
#include "ASMTRefSurface.h"
#include "ASMTTime.h"
#include "SystemSolver.h"
#include "ASMTItemIJ.h"
#include "ASMTKinematicIJ.h"
using namespace MbD;
void MbD::ASMTAssembly::runFile(const char* fileName)
void MbD::ASMTAssembly::runSinglePendulum()
{
auto assembly = CREATE<ASMTAssembly>::With();
std::string str = "";
assembly->setNotes(str);
str = "Assembly1";
assembly->setName(str);
auto pos3D = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
assembly->setPosition3D(pos3D);
auto rotMat = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
assembly->setRotationMatrix(rotMat);
auto vel3D = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
assembly->setVelocity3D(vel3D);
auto ome3D = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
assembly->setOmega3D(ome3D);
//
auto massMarker = CREATE<ASMTPrincipalMassMarker>::With();
massMarker->setMass(0.0);
massMarker->setDensity(0.0);
auto aJ = std::make_shared<DiagonalMatrix<double>>(ListD{ 0, 0, 0 });
massMarker->setMomentOfInertias(aJ);
pos3D = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
massMarker->setPosition3D(pos3D);
rotMat = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
massMarker->setRotationMatrix(rotMat);
assembly->setPrincipalMassMarker(massMarker);
//
auto mkr = CREATE<ASMTMarker>::With();
str = "Marker1";
mkr->setName(str);
pos3D = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
mkr->setPosition3D(pos3D);
rotMat = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
massMarker->setRotationMatrix(rotMat);
assembly->addMarker(mkr);
//
auto part = CREATE<ASMTPart>::With();
str = "Part1";
part->setName(str);
pos3D = std::make_shared<FullColumn<double>>(ListD{ -0.1, -0.1, -0.1 });
part->setPosition3D(pos3D);
rotMat = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
part->setRotationMatrix(rotMat);
vel3D = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
part->setVelocity3D(vel3D);
ome3D = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
part->setOmega3D(ome3D);
assembly->addPart(part);
//
massMarker = CREATE<ASMTPrincipalMassMarker>::With();
massMarker->setMass(0.2);
massMarker->setDensity(10.0);
aJ = std::make_shared<DiagonalMatrix<double>>(ListD{ 8.3333333333333e-4, 0.016833333333333, 0.017333333333333 });
massMarker->setMomentOfInertias(aJ);
pos3D = std::make_shared<FullColumn<double>>(ListD{ 0.5, 0.1, 0.05 });
massMarker->setPosition3D(pos3D);
rotMat = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
massMarker->setRotationMatrix(rotMat);
part->setPrincipalMassMarker(massMarker);
//
mkr = CREATE<ASMTMarker>::With();
str = "Marker1";
mkr->setName(str);
pos3D = std::make_shared<FullColumn<double>>(ListD{ 0.1, 0.1, 0.1 });
mkr->setPosition3D(pos3D);
rotMat = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
mkr->setRotationMatrix(rotMat);
part->addMarker(mkr);
//
auto joint = CREATE<ASMTRevoluteJoint>::With();
str = "Joint1";
joint->setName(str);
str = "/Assembly1/Marker1";
joint->setMarkerI(str);
str = "/Assembly1/Part1/Marker1";
joint->setMarkerJ(str);
assembly->addJoint(joint);
//
auto motion = CREATE<ASMTRotationalMotion>::With();
str = "Motion1";
motion->setName(str);
str = "/Assembly1/Joint1";
motion->setMotionJoint(str);
str = "0.0";
motion->setRotationZ(str);
assembly->addMotion(motion);
//
auto constantGravity = CREATE<ASMTConstantGravity>::With();
auto gAcceleration = std::make_shared<FullColumn<double>>(ListD{ 0.0, 0.0, 0.0 });
constantGravity->setg(gAcceleration);
assembly->setConstantGravity(constantGravity);
//
auto simulationParameters = CREATE<ASMTSimulationParameters>::With();
simulationParameters->settstart(0.0);
simulationParameters->settend(0.0); //tstart == tend Initial Conditions only.
simulationParameters->sethmin(1.0e-9);
simulationParameters->sethmax(1.0);
simulationParameters->sethout(0.04);
simulationParameters->seterrorTol(1.0e-6);
assembly->setSimulationParameters(simulationParameters);
//
assembly->runKINEMATIC();
}
void MbD::ASMTAssembly::runFile(const char* chars)
{
std::ifstream stream(fileName);
if(stream.fail()) {
@@ -53,11 +194,22 @@ void MbD::ASMTAssembly::runFile(const char* fileName)
}
void MbD::ASMTAssembly::initialize()
{
ASMTSpatialContainer::initialize();
times = std::make_shared<FullRow<double>>();
}
ASMTAssembly* MbD::ASMTAssembly::root()
{
return this;
}
void MbD::ASMTAssembly::setNotes(std::string& str)
{
notes = str;
}
void MbD::ASMTAssembly::parseASMT(std::vector<std::string>& lines)
{
readNotes(lines);
@@ -96,7 +248,7 @@ void MbD::ASMTAssembly::readParts(std::vector<std::string>& lines)
{
assert(lines[0] == "\tParts");
lines.erase(lines.begin());
parts = std::make_shared<std::vector<std::shared_ptr<ASMTPart>>>();
parts->clear();
auto it = std::find(lines.begin(), lines.end(), "\tKinematicIJs");
std::vector<std::string> partsLines(lines.begin(), it);
while (!partsLines.empty()) {
@@ -120,7 +272,7 @@ void MbD::ASMTAssembly::readKinematicIJs(std::vector<std::string>& lines)
{
assert(lines[0] == "\tKinematicIJs");
lines.erase(lines.begin());
kinematicIJs = std::make_shared<std::vector<std::shared_ptr<ASMTKinematicIJ>>>();
kinematicIJs->clear();
auto it = std::find(lines.begin(), lines.end(), "\tConstraintSets");
std::vector<std::string> kinematicIJsLines(lines.begin(), it);
while (!kinematicIJsLines.empty()) {
@@ -148,7 +300,7 @@ void MbD::ASMTAssembly::readJoints(std::vector<std::string>& lines)
{
assert(lines[0] == "\t\tJoints");
lines.erase(lines.begin());
joints = std::make_shared<std::vector<std::shared_ptr<ASMTJoint>>>();
joints->clear();
auto it = std::find(lines.begin(), lines.end(), "\t\tMotions");
std::vector<std::string> jointsLines(lines.begin(), it);
std::shared_ptr<ASMTJoint> joint;
@@ -190,7 +342,7 @@ void MbD::ASMTAssembly::readMotions(std::vector<std::string>& lines)
{
assert(lines[0] == "\t\tMotions");
lines.erase(lines.begin());
motions = std::make_shared<std::vector<std::shared_ptr<ASMTMotion>>>();
motions->clear();
auto it = std::find(lines.begin(), lines.end(), "\t\tGeneralConstraintSets");
std::vector<std::string> motionsLines(lines.begin(), it);
std::shared_ptr<ASMTMotion> motion;
@@ -221,7 +373,7 @@ void MbD::ASMTAssembly::readGeneralConstraintSets(std::vector<std::string>& line
{
assert(lines[0] == "\t\tGeneralConstraintSets");
lines.erase(lines.begin());
constraintSets = std::make_shared<std::vector<std::shared_ptr<ASMTConstraintSet>>>();
constraintSets->clear();
auto it = std::find(lines.begin(), lines.end(), "\tForceTorques");
std::vector<std::string> generalConstraintSetsLines(lines.begin(), it);
while (!generalConstraintSetsLines.empty()) {
@@ -234,7 +386,7 @@ void MbD::ASMTAssembly::readForcesTorques(std::vector<std::string>& lines)
{
assert(lines[0] == "\tForceTorques"); //Spelling is not consistent in asmt file.
lines.erase(lines.begin());
forcesTorques = std::make_shared<std::vector<std::shared_ptr<ASMTForceTorque>>>();
forcesTorques->clear();
auto it = std::find(lines.begin(), lines.end(), "\tConstantGravity");
std::vector<std::string> forcesTorquesLines(lines.begin(), it);
while (!forcesTorquesLines.empty()) {
@@ -540,7 +692,7 @@ void MbD::ASMTAssembly::createMbD(std::shared_ptr<System> mbdSys, std::shared_pt
for (auto& joint : *jointsMotions) { joint->createMbD(mbdSys, mbdUnits); }
for (auto& forceTorque : *forcesTorques) { forceTorque->createMbD(mbdSys, mbdUnits); }
auto mbdSysSolver = mbdSys->systemSolver;
auto& mbdSysSolver = mbdSys->systemSolver;
mbdSysSolver->errorTolPosKine = simulationParameters->errorTolPosKine;
mbdSysSolver->errorTolAccKine = simulationParameters->errorTolAccKine;
mbdSysSolver->iterMaxPosKine = simulationParameters->iterMaxPosKine;
@@ -585,9 +737,9 @@ void MbD::ASMTAssembly::initprincipalMassMarker()
principalMassMarker->mass = 0.0;
principalMassMarker->density = 0.0;
principalMassMarker->momentOfInertias = std::make_shared<DiagonalMatrix<double>>(3, 0);
principalMassMarker->position3D = std::make_shared<FullColumn<double>>(3, 0);
principalMassMarker->rotationMatrix = std::make_shared<FullMatrix<double>>(3, 3);
principalMassMarker->rotationMatrix->identity();
//principalMassMarker->position3D = std::make_shared<FullColumn<double>>(3, 0);
//principalMassMarker->rotationMatrix = std::make_shared<FullMatrix<double>>(3, 3);
//principalMassMarker->rotationMatrix->identity();
}
std::shared_ptr<ASMTSpatialContainer> MbD::ASMTAssembly::spatialContainerAt(std::shared_ptr<ASMTAssembly> self, std::string& longname)
@@ -662,11 +814,7 @@ std::shared_ptr<ASMTTime> MbD::ASMTAssembly::geoTime()
void MbD::ASMTAssembly::updateFromMbD()
{
ASMTSpatialContainer::updateFromMbD();
auto geoTime = asmtTime->getValue();
auto it = std::find_if(times->begin(), times->end(), [&](double t) {
return Numeric::equaltol(t, geoTime, 1.0e-9);
});
assert(it != times->end());
times->push_back(asmtTime->getValue());
for (auto& part : *parts) part->updateFromMbD();
for (auto& joint : *joints) joint->updateFromMbD();
for (auto& motion : *motions) motion->updateFromMbD();
@@ -682,4 +830,44 @@ void MbD::ASMTAssembly::compareResults(AnalysisType type)
for (auto& forceTorque : *forcesTorques) forceTorque->compareResults(type);
}
void MbD::ASMTAssembly::outputResults(AnalysisType type)
{
ASMTSpatialContainer::outputResults(type);
for (auto& part : *parts) part->outputResults(type);
for (auto& joint : *joints) joint->outputResults(type);
for (auto& motion : *motions) motion->outputResults(type);
for (auto& forceTorque : *forcesTorques) forceTorque->outputResults(type);
}
void MbD::ASMTAssembly::addPart(std::shared_ptr<ASMTPart> part)
{
parts->push_back(part);
part->owner = this;
}
void MbD::ASMTAssembly::addJoint(std::shared_ptr<ASMTJoint> joint)
{
joints->push_back(joint);
joint->owner = this;
}
void MbD::ASMTAssembly::addMotion(std::shared_ptr<ASMTMotion> motion)
{
motions->push_back(motion);
motion->owner = this;
motion->initMarkers();
}
void MbD::ASMTAssembly::setConstantGravity(std::shared_ptr<ASMTConstantGravity> gravity)
{
constantGravity = gravity;
gravity->owner = this;
}
void MbD::ASMTAssembly::setSimulationParameters(std::shared_ptr<ASMTSimulationParameters> parameters)
{
simulationParameters = parameters;
parameters->owner = this;
}

View File

@@ -5,100 +5,111 @@
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include <fstream>
#include "ASMTSpatialContainer.h"
#include "ASMTRefPoint.h"
#include "ASMTRefCurve.h"
#include "ASMTRefSurface.h"
#include "ASMTPart.h"
#include "ASMTKinematicIJ.h"
#include "ASMTConstraintSet.h"
#include "ASMTForceTorque.h"
#include "ASMTConstantGravity.h"
#include "ASMTSimulationParameters.h"
#include "ASMTAnimationParameters.h"
#include "FullColumn.h"
#include "FullMatrix.h"
#include "ASMTJoint.h"
#include "ASMTMotion.h"
#include "Units.h"
#include "ASMTTime.h"
#include "SystemSolver.h"
namespace MbD {
class ASMTAssembly : public ASMTSpatialContainer
{
//
public:
static void runFile(const char* fileName);
ASMTAssembly* root() override;
void parseASMT(std::vector<std::string>& lines) override;
void readNotes(std::vector<std::string>& lines);
void readParts(std::vector<std::string>& lines);
void readPart(std::vector<std::string>& lines);
void readKinematicIJs(std::vector<std::string>& lines);
void readKinematicIJ(std::vector<std::string>& lines);
void readConstraintSets(std::vector<std::string>& lines);
void readJoints(std::vector<std::string>& lines);
void readMotions(std::vector<std::string>& lines);
void readGeneralConstraintSets(std::vector<std::string>& lines);
void readForcesTorques(std::vector<std::string>& lines);
void readConstantGravity(std::vector<std::string>& lines);
void readSimulationParameters(std::vector<std::string>& lines);
void readAnimationParameters(std::vector<std::string>& lines);
void readTimeSeries(std::vector<std::string>& lines);
void readTimes(std::vector<std::string>& lines);
void readAssemblySeries(std::vector<std::string>& lines);
void readPartSeriesMany(std::vector<std::string>& lines);
void readPartSeries(std::vector<std::string>& lines);
void readJointSeriesMany(std::vector<std::string>& lines);
void readJointSeries(std::vector<std::string>& lines);
void readMotionSeriesMany(std::vector<std::string>& lines);
void readMotionSeries(std::vector<std::string>& lines);
class ASMTRefPoint;
class ASMTRefCurve;
class ASMTRefSurface;
class ASMTPart;
class ASMTKinematicIJ;
class ASMTConstraintSet;
class ASMTForceTorque;
class ASMTConstantGravity;
class ASMTSimulationParameters;
class ASMTAnimationParameters;
class ASMTJoint;
class ASMTMotion;
class Units;
class ASMTTime;
class SystemSolver;
class ASMTItemIJ;
void outputFor(AnalysisType type);
void logString(std::string& str);
void logString(double value);
void preMbDrun(std::shared_ptr<System> mbdSys);
void postMbDrun();
void calcCharacteristicDimensions();
double calcCharacteristicTime();
double calcCharacteristicMass();
double calcCharacteristicLength();
std::shared_ptr<std::vector<std::shared_ptr<ASMTItemIJ>>> connectorList();
std::shared_ptr<std::map<std::string, std::shared_ptr<ASMTMarker>>>markerMap();
void deleteMbD();
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void runKINEMATIC();
void initprincipalMassMarker();
std::shared_ptr<ASMTSpatialContainer> spatialContainerAt(std::shared_ptr<ASMTAssembly> self, std::string& longname);
std::shared_ptr<ASMTMarker> markerAt(std::string& longname);
std::shared_ptr<ASMTJoint> jointAt(std::string& longname);
std::shared_ptr<ASMTMotion> motionAt(std::string& longname);
std::shared_ptr<ASMTForceTorque> forceTorqueAt(std::string& longname);
FColDsptr vOcmO() override;
FColDsptr omeOpO() override;
std::shared_ptr<ASMTTime> geoTime();
void updateFromMbD() override;
void compareResults(AnalysisType type) override;
class ASMTAssembly : public ASMTSpatialContainer
{
//
public:
static void runSinglePendulum();
static void runFile(const char* chars);
void initialize() override;
ASMTAssembly* root() override;
void setNotes(std::string& str);
void parseASMT(std::vector<std::string>& lines) override;
void readNotes(std::vector<std::string>& lines);
void readParts(std::vector<std::string>& lines);
void readPart(std::vector<std::string>& lines);
void readKinematicIJs(std::vector<std::string>& lines);
void readKinematicIJ(std::vector<std::string>& lines);
void readConstraintSets(std::vector<std::string>& lines);
void readJoints(std::vector<std::string>& lines);
void readMotions(std::vector<std::string>& lines);
void readGeneralConstraintSets(std::vector<std::string>& lines);
void readForcesTorques(std::vector<std::string>& lines);
void readConstantGravity(std::vector<std::string>& lines);
void readSimulationParameters(std::vector<std::string>& lines);
void readAnimationParameters(std::vector<std::string>& lines);
void readTimeSeries(std::vector<std::string>& lines);
void readTimes(std::vector<std::string>& lines);
void readAssemblySeries(std::vector<std::string>& lines);
void readPartSeriesMany(std::vector<std::string>& lines);
void readPartSeries(std::vector<std::string>& lines);
void readJointSeriesMany(std::vector<std::string>& lines);
void readJointSeries(std::vector<std::string>& lines);
void readMotionSeriesMany(std::vector<std::string>& lines);
void readMotionSeries(std::vector<std::string>& lines);
std::string notes;
std::shared_ptr<std::vector<std::shared_ptr<ASMTPart>>> parts;
std::shared_ptr<std::vector<std::shared_ptr<ASMTKinematicIJ>>> kinematicIJs;
std::shared_ptr<std::vector<std::shared_ptr<ASMTConstraintSet>>> constraintSets;
std::shared_ptr<std::vector<std::shared_ptr<ASMTJoint>>> joints;
std::shared_ptr<std::vector<std::shared_ptr<ASMTMotion>>> motions;
std::shared_ptr<std::vector<std::shared_ptr<ASMTForceTorque>>> forcesTorques;
std::shared_ptr<ASMTConstantGravity> constantGravity;
std::shared_ptr<ASMTSimulationParameters> simulationParameters;
std::shared_ptr<ASMTAnimationParameters> animationParameters;
std::shared_ptr<std::vector<double>> times;
std::shared_ptr<ASMTTime> asmtTime = std::make_shared<ASMTTime>();
std::shared_ptr<Units> mbdUnits;
void outputFor(AnalysisType type);
void logString(std::string& str);
void logString(double value);
void preMbDrun(std::shared_ptr<System> mbdSys);
void postMbDrun();
void calcCharacteristicDimensions();
double calcCharacteristicTime();
double calcCharacteristicMass();
double calcCharacteristicLength();
std::shared_ptr<std::vector<std::shared_ptr<ASMTItemIJ>>> connectorList();
std::shared_ptr<std::map<std::string, std::shared_ptr<ASMTMarker>>>markerMap();
void deleteMbD();
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void runKINEMATIC();
void initprincipalMassMarker();
std::shared_ptr<ASMTSpatialContainer> spatialContainerAt(std::shared_ptr<ASMTAssembly> self, std::string& longname);
std::shared_ptr<ASMTMarker> markerAt(std::string& longname);
std::shared_ptr<ASMTJoint> jointAt(std::string& longname);
std::shared_ptr<ASMTMotion> motionAt(std::string& longname);
std::shared_ptr<ASMTForceTorque> forceTorqueAt(std::string& longname);
FColDsptr vOcmO() override;
FColDsptr omeOpO() override;
std::shared_ptr<ASMTTime> geoTime();
void updateFromMbD() override;
void compareResults(AnalysisType type) override;
void outputResults(AnalysisType type) override;
void addPart(std::shared_ptr<ASMTPart> part);
void addJoint(std::shared_ptr<ASMTJoint> joint);
void addMotion(std::shared_ptr<ASMTMotion> motion);
void setConstantGravity(std::shared_ptr<ASMTConstantGravity> constantGravity);
void setSimulationParameters(std::shared_ptr<ASMTSimulationParameters> simulationParameters);
};
std::string notes;
std::shared_ptr<std::vector<std::shared_ptr<ASMTPart>>> parts = std::make_shared<std::vector<std::shared_ptr<ASMTPart>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTKinematicIJ>>> kinematicIJs = std::make_shared<std::vector<std::shared_ptr<ASMTKinematicIJ>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTConstraintSet>>> constraintSets = std::make_shared<std::vector<std::shared_ptr<ASMTConstraintSet>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTJoint>>> joints = std::make_shared<std::vector<std::shared_ptr<ASMTJoint>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTMotion>>> motions = std::make_shared<std::vector<std::shared_ptr<ASMTMotion>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTForceTorque>>> forcesTorques = std::make_shared<std::vector<std::shared_ptr<ASMTForceTorque>>>();
std::shared_ptr<ASMTConstantGravity> constantGravity;
std::shared_ptr<ASMTSimulationParameters> simulationParameters;
std::shared_ptr<ASMTAnimationParameters> animationParameters;
std::shared_ptr<std::vector<double>> times;
std::shared_ptr<ASMTTime> asmtTime = std::make_shared<ASMTTime>();
std::shared_ptr<Units> mbdUnits;
};
}

View File

@@ -28,3 +28,8 @@ void MbD::ASMTConstantGravity::createMbD(std::shared_ptr<System> mbdSys, std::sh
mbdGravity->gXYZ = g->times(1.0 / mbdUnits->acceleration);
mbdSys->addForceTorque(mbdGravity);
}
void MbD::ASMTConstantGravity::setg(FColDsptr gravity)
{
g = gravity;
}

View File

@@ -21,6 +21,7 @@ namespace MbD {
public:
void parseASMT(std::vector<std::string>& lines) override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void setg(FColDsptr g);
FColDsptr g;
};

View File

@@ -58,6 +58,7 @@ void MbD::ASMTConstraintSet::updateFromMbD()
void MbD::ASMTConstraintSet::compareResults(AnalysisType type)
{
if (infxs == nullptr || infxs->empty()) return;
auto mbdUnts = mbdUnits();
auto factor = 1.0e-6;
auto forceTol = mbdUnts->force * factor;
@@ -70,3 +71,7 @@ void MbD::ASMTConstraintSet::compareResults(AnalysisType type)
//assert(Numeric::equaltol(tys->at(i), intys->at(i), torqueTol));
//assert(Numeric::equaltol(tzs->at(i), intzs->at(i), torqueTol));
}
void MbD::ASMTConstraintSet::outputResults(AnalysisType type)
{
}

View File

@@ -21,6 +21,7 @@ namespace MbD {
virtual std::shared_ptr<Joint> mbdClassNew();
void updateFromMbD() override;
void compareResults(AnalysisType type) override;
void outputResults(AnalysisType type) override;
};
}

View File

@@ -19,3 +19,8 @@ void MbD::ASMTForceTorque::compareResults(AnalysisType type)
{
assert(false);
}
void MbD::ASMTForceTorque::outputResults(AnalysisType type)
{
assert(false);
}

View File

@@ -17,6 +17,7 @@ namespace MbD {
public:
void updateFromMbD() override;
void compareResults(AnalysisType type) override;
void outputResults(AnalysisType type) override;
};

View File

@@ -13,6 +13,8 @@
#include "CREATE.h"
#include "Constant.h"
#include "EulerAngles.h"
#include "FullMotion.h"
#include "ASMTTime.h"
using namespace MbD;

View File

@@ -9,7 +9,6 @@
#pragma once
#include "ASMTMotion.h"
#include "FullMotion.h"
namespace MbD {
class ASMTGeneralMotion : public ASMTMotion

View File

@@ -28,6 +28,11 @@ void MbD::ASMTItem::initialize()
{
}
void MbD::ASMTItem::setName(std::string& str)
{
name = str;
}
void MbD::ASMTItem::parseASMT(std::vector<std::string>& lines)
{
assert(false);
@@ -141,6 +146,11 @@ void MbD::ASMTItem::compareResults(AnalysisType type)
assert(false);
}
void MbD::ASMTItem::outputResults(AnalysisType type)
{
assert(false);
}
std::shared_ptr<Units> MbD::ASMTItem::mbdUnits()
{
if (owner) {

View File

@@ -22,6 +22,7 @@ namespace MbD {
virtual std::shared_ptr<ASMTSpatialContainer> part();
virtual void initialize();
void setName(std::string& str);
virtual void parseASMT(std::vector<std::string>& lines);
FRowDsptr readRowOfDoubles(std::string& line);
FColDsptr readColumnOfDoubles(std::string& line);
@@ -36,6 +37,7 @@ namespace MbD {
virtual void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits);
virtual void updateFromMbD();
virtual void compareResults(AnalysisType type);
virtual void outputResults(AnalysisType type);
std::shared_ptr<Units> mbdUnits();
std::shared_ptr<Constant> sptrConstant(double value);

View File

@@ -18,6 +18,16 @@ void MbD::ASMTItemIJ::initialize()
tzs = std::make_shared<FullRow<double>>();
}
void MbD::ASMTItemIJ::setMarkerI(std::string& mkrI)
{
markerI = mkrI;
}
void MbD::ASMTItemIJ::setMarkerJ(std::string& mkrJ)
{
markerJ = mkrJ;
}
void MbD::ASMTItemIJ::readMarkerI(std::vector<std::string>& lines)
{
assert(lines[0].find("MarkerI") != std::string::npos);

View File

@@ -16,6 +16,8 @@ namespace MbD {
//
public:
void initialize() override;
void setMarkerI(std::string& mkrI);
void setMarkerJ(std::string& mkrJ);
void readMarkerI(std::vector<std::string>& lines);
void readMarkerJ(std::vector<std::string>& lines);
void readFXonIs(std::vector<std::string>& lines);

View File

@@ -12,6 +12,7 @@
#include "Part.h"
#include "PartFrame.h"
#include "MarkerFrame.h"
#include "ASMTPrincipalMassMarker.h"
using namespace MbD;

View File

@@ -8,6 +8,8 @@
#include "ASMTPart.h"
#include "CREATE.h"
#include "ASMTPrincipalMassMarker.h"
using namespace MbD;

View File

@@ -9,13 +9,10 @@
#pragma once
#include "ASMTSpatialContainer.h"
#include "ASMTRefPoint.h"
#include "ASMTRefCurve.h"
#include "ASMTRefSurface.h"
#include "ASMTPrincipalMassMarker.h"
#include "PosVelAccData.h"
namespace MbD {
class PosVelAccData;
class ASMTPart : public ASMTSpatialContainer
{
//

View File

@@ -51,3 +51,18 @@ void MbD::ASMTPrincipalMassMarker::parseASMT(std::vector<std::string>& lines)
density = readDouble(lines[0]);
lines.erase(lines.begin());
}
void MbD::ASMTPrincipalMassMarker::setMass(double m)
{
mass = m;
}
void MbD::ASMTPrincipalMassMarker::setDensity(double rho)
{
density = rho;
}
void MbD::ASMTPrincipalMassMarker::setMomentOfInertias(DiagMatDsptr mat)
{
momentOfInertias = mat;
}

View File

@@ -8,17 +8,18 @@
#pragma once
#include "ASMTItem.h"
#include "ASMTSpatialItem.h"
namespace MbD {
class ASMTPrincipalMassMarker : public ASMTItem
class ASMTPrincipalMassMarker : public ASMTSpatialItem
{
//
public:
void parseASMT(std::vector<std::string>& lines) override;
void setMass(double mass);
void setDensity(double density);
void setMomentOfInertias(DiagMatDsptr momentOfInertias);
FColDsptr position3D;
FMatDsptr rotationMatrix;
double mass, density;
DiagMatDsptr momentOfInertias;

View File

@@ -11,11 +11,17 @@
using namespace MbD;
void MbD::ASMTRefItem::addMarker(std::shared_ptr<ASMTMarker> marker)
{
markers->push_back(marker);
marker->owner = this;
}
void MbD::ASMTRefItem::readMarkers(std::vector<std::string>& lines)
{
assert(lines[0].find("Markers") != std::string::npos);
lines.erase(lines.begin());
markers = std::make_shared<std::vector<std::shared_ptr<ASMTMarker>>>();
markers->clear();
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
return s.find("RefPoint") != std::string::npos;
});

View File

@@ -17,10 +17,11 @@ namespace MbD {
{
//
public:
void addMarker(std::shared_ptr<ASMTMarker> marker);
void readMarkers(std::vector<std::string>& lines);
void readMarker(std::vector<std::string>& lines);
std::shared_ptr<std::vector<std::shared_ptr<ASMTMarker>>> markers;
std::shared_ptr<std::vector<std::shared_ptr<ASMTMarker>>> markers = std::make_shared<std::vector<std::shared_ptr<ASMTMarker>>>();
};

View File

@@ -12,6 +12,8 @@
#include "BasicUserFunction.h"
#include "CREATE.h"
#include "Constant.h"
#include "ASMTJoint.h"
#include "ASMTTime.h"
using namespace MbD;
@@ -64,3 +66,13 @@ std::shared_ptr<Joint> MbD::ASMTRotationalMotion::mbdClassNew()
{
return CREATE<ZRotation>::With();
}
void MbD::ASMTRotationalMotion::setMotionJoint(std::string& str)
{
motionJoint = str;
}
void MbD::ASMTRotationalMotion::setRotationZ(std::string& rotZ)
{
rotationZ = rotZ;
}

View File

@@ -22,6 +22,8 @@ namespace MbD {
void initMarkers() override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
std::shared_ptr<Joint> mbdClassNew() override;
void setMotionJoint(std::string& motionJoint);
void setRotationZ(std::string& rotZ);
std::string motionJoint, rotationZ;
};

View File

@@ -42,3 +42,33 @@ void MbD::ASMTSimulationParameters::parseASMT(std::vector<std::string>& lines)
lines.erase(lines.begin());
}
void MbD::ASMTSimulationParameters::settstart(double t)
{
tstart = t;
}
void MbD::ASMTSimulationParameters::settend(double t)
{
tend = t;
}
void MbD::ASMTSimulationParameters::sethmin(double h)
{
hmin = h;
}
void MbD::ASMTSimulationParameters::sethmax(double h)
{
hmax = h;
}
void MbD::ASMTSimulationParameters::sethout(double h)
{
hout = h;
}
void MbD::ASMTSimulationParameters::seterrorTol(double tol)
{
errorTol = tol;
}

View File

@@ -16,6 +16,12 @@ namespace MbD {
//
public:
void parseASMT(std::vector<std::string>& lines) override;
void settstart(double tstart);
void settend(double tend);
void sethmin(double hmin);
void sethmax(double hmax);
void sethout(double hout);
void seterrorTol(double errorTol);
double tstart = 0.0, tend = 1.0, hmin = 1.0e-9, hmax = 1.0e9, hout = 0.1, errorTol = 1.0e-6;
double errorTolPosKine = 1.0e-6, errorTolAccKine = 1.0e-6, corAbsTol = 1.0e-6, corRelTol = 1.0e-6;

View File

@@ -10,11 +10,20 @@
#include "Units.h"
#include "Part.h"
#include "System.h"
#include "ASMTRefPoint.h"
#include "ASMTRefCurve.h"
#include "ASMTRefSurface.h"
#include "ASMTPrincipalMassMarker.h"
using namespace MbD;
void MbD::ASMTSpatialContainer::initialize()
{
refPoints = std::make_shared<std::vector<std::shared_ptr<ASMTRefPoint>>>();
refCurves = std::make_shared<std::vector<std::shared_ptr<ASMTRefCurve>>>();
refSurfaces = std::make_shared<std::vector<std::shared_ptr<ASMTRefSurface>>>();
xs = std::make_shared<FullRow<double>>();
ys = std::make_shared<FullRow<double>>();
zs = std::make_shared<FullRow<double>>();
@@ -35,11 +44,16 @@ void MbD::ASMTSpatialContainer::initialize()
alpzs = std::make_shared<FullRow<double>>();
}
void MbD::ASMTSpatialContainer::setPrincipalMassMarker(std::shared_ptr<ASMTPrincipalMassMarker> aJ)
{
principalMassMarker = aJ;
}
void MbD::ASMTSpatialContainer::readRefPoints(std::vector<std::string>& lines)
{
assert(lines[0].find("RefPoints") != std::string::npos);
lines.erase(lines.begin());
refPoints = std::make_shared<std::vector<std::shared_ptr<ASMTRefPoint>>>();
refPoints->clear();
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
return s.find("RefCurves") != std::string::npos;
});
@@ -64,7 +78,7 @@ void MbD::ASMTSpatialContainer::readRefCurves(std::vector<std::string>& lines)
{
assert(lines[0].find("RefCurves") != std::string::npos);
lines.erase(lines.begin());
refCurves = std::make_shared<std::vector<std::shared_ptr<ASMTRefCurve>>>();
refCurves->clear();
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
return s.find("RefSurfaces") != std::string::npos;
});
@@ -84,7 +98,7 @@ void MbD::ASMTSpatialContainer::readRefSurfaces(std::vector<std::string>& lines)
{
assert(lines[0].find("RefSurfaces") != std::string::npos);
lines.erase(lines.begin());
refSurfaces = std::make_shared<std::vector<std::shared_ptr<ASMTRefSurface>>>();
refSurfaces->clear();
auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& s) {
return s.find("Part") != std::string::npos;
});
@@ -325,6 +339,7 @@ void MbD::ASMTSpatialContainer::updateFromMbD()
void MbD::ASMTSpatialContainer::compareResults(AnalysisType type)
{
if (inxs == nullptr || inxs->empty()) return;
auto mbdUnts = mbdUnits();
auto factor = 1.0e-6;
auto lengthTol = mbdUnts->length * factor;
@@ -392,3 +407,25 @@ void MbD::ASMTSpatialContainer::compareResults(AnalysisType type)
std::cout << i << " alpzs " << alpzs->at(i) << ", " << inalpzs->at(i) << ", " << alphaTol << std::endl;
}
}
void MbD::ASMTSpatialContainer::outputResults(AnalysisType type)
{
if (inxs != nullptr && !inxs->empty()) return;
auto i = xs->size() - 1;
std::cout << i << " ";
std::cout << xs->at(i) << ", " << ys->at(i) << ", " << zs->at(i) << ", ";
std::cout << bryxs->at(i) << ", " << bryys->at(i) << ", " << bryzs->at(i) << std::endl;
}
void MbD::ASMTSpatialContainer::addRefPoint(std::shared_ptr<ASMTRefPoint> refPoint)
{
refPoints->push_back(refPoint);
refPoint->owner = this;
}
void MbD::ASMTSpatialContainer::addMarker(std::shared_ptr<ASMTMarker> marker)
{
auto refPoint = CREATE<ASMTRefPoint>::With();
addRefPoint(refPoint);
refPoint->addMarker(marker);
}

View File

@@ -9,18 +9,32 @@
#pragma once
#include "ASMTSpatialItem.h"
#include "ASMTRefPoint.h"
#include "ASMTRefCurve.h"
#include "ASMTRefSurface.h"
#include "ASMTPrincipalMassMarker.h"
#include "Units.h"
//#include "ASMTRefPoint.h"
//#include "ASMTRefCurve.h"
//#include "ASMTRefSurface.h"
//#include "ASMTPrincipalMassMarker.h"
//#include "Units.h"
//#include "ASMTPart.h"
//#include "ASMTJoint.h"
//#include "ASMTMotion.h"
namespace MbD {
class ASMTRefPoint;
class ASMTRefCurve;
class ASMTRefSurface;
class ASMTPrincipalMassMarker;
class Units;
class ASMTPart;
class ASMTJoint;
class ASMTMotion;
class ASMTMarker;
class ASMTSpatialContainer : public ASMTSpatialItem
{
//
public:
void initialize() override;
void setPrincipalMassMarker(std::shared_ptr<ASMTPrincipalMassMarker> aJ);
void readRefPoints(std::vector<std::string>& lines);
void readRefPoint(std::vector<std::string>& lines);
void readRefCurves(std::vector<std::string>& lines);
@@ -53,6 +67,9 @@ namespace MbD {
std::shared_ptr<ASMTSpatialContainer> part() override;
void updateFromMbD() override;
void compareResults(AnalysisType type) override;
void outputResults(AnalysisType type) override;
void addRefPoint(std::shared_ptr<ASMTRefPoint> refPoint);
void addMarker(std::shared_ptr<ASMTMarker> marker);
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefPoint>>> refPoints;
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefCurve>>> refCurves;

View File

@@ -10,6 +10,26 @@
using namespace MbD;
void MbD::ASMTSpatialItem::setPosition3D(FColDsptr vec)
{
position3D = vec;
}
void MbD::ASMTSpatialItem::setRotationMatrix(FMatDsptr mat)
{
rotationMatrix = mat;
}
void MbD::ASMTSpatialItem::setVelocity3D(FColDsptr vec)
{
velocity3D = vec;
}
void MbD::ASMTSpatialItem::setOmega3D(FColDsptr vec)
{
omega3D = vec;
}
void MbD::ASMTSpatialItem::readPosition3D(std::vector<std::string>& lines)
{
assert(lines[0].find("Position3D") != std::string::npos);

View File

@@ -5,7 +5,7 @@
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTItem.h"
@@ -15,13 +15,23 @@ namespace MbD {
{
//
public:
void setPosition3D(FColDsptr position3D);
void setRotationMatrix(FMatDsptr rotationMatrix);
void setVelocity3D(FColDsptr velocity3D);
void setOmega3D(FColDsptr omega3D);
void readPosition3D(std::vector<std::string>& lines);
void readRotationMatrix(std::vector<std::string>& lines);
void readVelocity3D(std::vector<std::string>& lines);
void readOmega3D(std::vector<std::string>& lines);
FColDsptr position3D, velocity3D, omega3D;
FMatDsptr rotationMatrix;
FColDsptr position3D = std::make_shared<FullColumn<double>>(3);
FColDsptr velocity3D = std::make_shared<FullColumn<double>>(3);
FColDsptr omega3D = std::make_shared<FullColumn<double>>(3);
FMatDsptr rotationMatrix = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
};
}

View File

@@ -11,6 +11,9 @@
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "Constant.h"
#include "ASMTJoint.h"
#include "ZTranslation.h"
#include "ASMTTime.h"
using namespace MbD;

View File

@@ -9,7 +9,6 @@
#pragma once
#include "ASMTMotion.h"
#include "ZTranslation.h"
namespace MbD {
class ASMTTranslationalMotion : public ASMTMotion

View File

@@ -49,6 +49,141 @@ void CADSystem::logString(double value)
{
}
void CADSystem::runOndselSinglePendulum()
{
//Double pendulum with easy input numbers for exact port from Smalltalk
//GEOAssembly calcCharacteristicDimensions must set mbdUnits to unity.
std::cout << "runOndselSinglePendulum" << std::endl;
auto& TheSystem = mbdSystem;
TheSystem->clear();
std::string name = "TheSystem";
TheSystem->name = name;
std::cout << "TheSystem->name " << TheSystem->name << std::endl;
auto& systemSolver = TheSystem->systemSolver;
systemSolver->errorTolPosKine = 1.0e-6;
systemSolver->errorTolAccKine = 1.0e-6;
systemSolver->iterMaxPosKine = 25;
systemSolver->iterMaxAccKine = 25;
systemSolver->tstart = 0.0;
systemSolver->tend = 0.04;
systemSolver->hmin = 1.0e-9;
systemSolver->hmax = 1.0;
systemSolver->hout = 0.04;
systemSolver->corAbsTol = 1.0e-6;
systemSolver->corRelTol = 1.0e-6;
systemSolver->intAbsTol = 1.0e-6;
systemSolver->intRelTol = 1.0e-6;
systemSolver->iterMaxDyn = 4;
systemSolver->orderMax = 5;
systemSolver->translationLimit = 1.0e10;
systemSolver->rotationLimit = 0.5;
std::string str;
FColDsptr qX, qE, qXdot, omeOpO, qXddot, alpOpO;
FColDsptr rpmp;
FMatDsptr aAap, aApm;
FRowDsptr fullRow;
//
auto assembly1 = CREATE<Part>::With("/Assembly1");
std::cout << "assembly1->name " << assembly1->name << std::endl;
assembly1->m = 0.0;
assembly1->aJ = std::make_shared<DiagonalMatrix<double>>(ListD{ 0, 0, 0 });
qX = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
aAap = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
assembly1->setqX(qX);
assembly1->setaAap(aAap);
qXdot = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
omeOpO = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
assembly1->setqXdot(qXdot);
assembly1->setomeOpO(omeOpO);
TheSystem->addPart(assembly1);
{
auto& partFrame = assembly1->partFrame;
auto marker2 = CREATE<MarkerFrame>::With("/Assembly1/Marker2");
rpmp = std::make_shared<FullColumn<double>>(ListD{ 0.0, 0.0, 0.0 });
marker2->setrpmp(rpmp);
aApm = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
marker2->setaApm(aApm);
partFrame->addMarkerFrame(marker2);
//
auto marker1 = CREATE<MarkerFrame>::With("/Assembly1/Marker1");
rpmp = std::make_shared<FullColumn<double>>(ListD{ 0.0, 3.0, 0.0 });
marker1->setrpmp(rpmp);
aApm = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 0, 1 },
{ 0, -1, 0 }
});
marker1->setaApm(aApm);
partFrame->addMarkerFrame(marker1);
}
assembly1->asFixed();
//
auto crankPart1 = CREATE<Part>::With("/Assembly1/Part1");
std::cout << "crankPart1->name " << crankPart1->name << std::endl;
crankPart1->m = 1.0;
crankPart1->aJ = std::make_shared<DiagonalMatrix<double>>(ListD{ 1, 1, 1 });
qX = std::make_shared<FullColumn<double>>(ListD{ 0.4, 0.0, -0.05 });
aAap = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
crankPart1->setqX(qX);
crankPart1->setaAap(aAap);
qXdot = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
omeOpO = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
crankPart1->setqXdot(qXdot);
crankPart1->setomeOpO(omeOpO);
TheSystem->addPart(crankPart1);
{
auto& partFrame = crankPart1->partFrame;
auto marker1 = CREATE<MarkerFrame>::With("/Assembly1/Part1/Marker1");
rpmp = std::make_shared<FullColumn<double>>(ListD{ -0.4, 0.0, 0.05 });
marker1->setrpmp(rpmp);
aApm = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
marker1->setaApm(aApm);
partFrame->addMarkerFrame(marker1);
//
auto marker2 = CREATE<MarkerFrame>::With("/Assembly1/Part1/Marker2");
rpmp = std::make_shared<FullColumn<double>>(ListD{ 0.4, 0.0, 0.05 });
marker2->setrpmp(rpmp);
aApm = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
marker2->setaApm(aApm);
partFrame->addMarkerFrame(marker2);
}
//
auto revJoint1 = CREATE<RevoluteJoint>::With("/Assembly1/Joint1");
std::cout << "revJoint1->name " << revJoint1->name << std::endl;
revJoint1->connectsItoJ(assembly1->partFrame->endFrame("/Assembly1/Marker2"), crankPart1->partFrame->endFrame("/Assembly1/Part1/Marker1"));
TheSystem->addJoint(revJoint1);
//
auto rotMotion1 = CREATE<ZRotation>::With("/Assembly1/Motion1");
rotMotion1->connectsItoJ(assembly1->partFrame->endFrame("/Assembly1/Marker2"), crankPart1->partFrame->endFrame("/Assembly1/Part1/Marker1"));
std::cout << "rotMotion1->name " << rotMotion1->name << std::endl;
rotMotion1->phiBlk = std::make_shared<Constant>(1.0);
std::cout << "rotMotion1->phiBlk " << *(rotMotion1->phiBlk) << std::endl;
TheSystem->addJoint(rotMotion1);
//
TheSystem->runKINEMATIC(TheSystem);
}
void CADSystem::runOndselDoublePendulum()
{
//Double pendulum with easy input numbers for exact port from Smalltalk
@@ -65,7 +200,7 @@ void CADSystem::runOndselDoublePendulum()
systemSolver->iterMaxPosKine = 25;
systemSolver->iterMaxAccKine = 25;
systemSolver->tstart = 0.0;
systemSolver->tend = 0.0;
systemSolver->tend = 0.04;
systemSolver->hmin = 1.0e-9;
systemSolver->hmax = 1.0;
systemSolver->hout = 0.04;

View File

@@ -27,6 +27,7 @@ namespace MbD {
void outputFor(AnalysisType type);
void logString(std::string& str);
void logString(double value);
void runOndselSinglePendulum();
void runOndselDoublePendulum();
void runOndselPiston();
void runPiston();

View File

@@ -34,6 +34,7 @@ void MbD::ExternalSystem::outputFor(AnalysisType type)
else if (asmtAssembly) {
asmtAssembly->updateFromMbD();
asmtAssembly->compareResults(type);
asmtAssembly->outputResults(type);
}
else {
assert(false);

View File

@@ -26,18 +26,20 @@ void runSpMat();
int main()
{
ASMTAssembly::runSinglePendulum();
ASMTAssembly::runFile("piston.asmt");
ASMTAssembly::runFile("00backhoe.asmt");
ASMTAssembly::runFile("circular.asmt");
//ASMTAssembly::runFile("cirpendu.asmt"); //Under constrained. Testing ICKine.
ASMTAssembly::runFile("cirpendu.asmt"); //Under constrained. Testing ICKine.
ASMTAssembly::runFile("engine1.asmt");
ASMTAssembly::runFile("fourbar.asmt");
ASMTAssembly::runFile("fourbot.asmt");
ASMTAssembly::runFile("wobpump.asmt");
auto cadSystem = std::make_shared<CADSystem>();
cadSystem->runOndselSinglePendulum();
cadSystem->runOndselDoublePendulum();
cadSystem->runOndselPiston();
//cadSystem->runOndselPiston();
cadSystem->runPiston();
runSpMat();
}

View File

@@ -153,6 +153,7 @@ void SystemSolver::runBasicCollision()
void SystemSolver::runBasicKinematic()
{
if (tstart == tend) return;
try {
basicIntegrator = CREATE<KineIntegrator>::With();
basicIntegrator->setSystem(this);

176
MbDCode/crank_slider.mbd Normal file
View File

@@ -0,0 +1,176 @@
# crank_slider.mbd
#-----------------------------------------------------------------------------
# [Data Block]
begin: data;
problem: initial value;
end: data;
#-----------------------------------------------------------------------------
# [<Problem> Block]
begin: initial value;
initial time: 0.;
final time: 5.;
time step: 1.e-2;
max iterations: 10;
tolerance: 1.e-6;
end: initial value;
#-----------------------------------------------------------------------------
# [Control Data Block]
begin: control data;
structural nodes: 4;
rigid bodies: 3;
joints: 6;
end: control data;
#-----------------------------------------------------------------------------
# Design Variables
set: real Mass_Crank = 1.;
set: real Mass_Conrod = 1.;
set: real Mass_Slider = 1.;
set: real Length_Crank = 0.2;
set: real Length_Conrod = 0.4;
set: real Offset_Slider = 0.05;
#-----------------------------------------------------------------------------
# Reference Labels
set: integer Ref_Conrod = 1;
# Node Labels
set: integer Node_Ground = 1;
set: integer Node_Crank = 2;
set: integer Node_Conrod = 3;
set: integer Node_Slider = 4;
# Body Labels
set: integer Body_Crank = 1;
set: integer Body_Conrod = 2;
set: integer Body_Slider = 3;
# Joint Labels
set: integer JoClamp_Ground = 1;
set: integer JoAxrot_Ground_Crank = 2;
set: integer JoRevh_Crank_Conrod = 3;
set: integer JoInlin_Conrod_Slider = 4;
set: integer JoInlin_Ground_Slider = 5;
set: integer JoPrism_Ground_Slider = 6;
#-----------------------------------------------------------------------------
# Intermediate Variables
set: real Izz_Crank = Mass_Crank*Length_Crank^2./12.;
set: real Izz_Conrod = Mass_Conrod*Length_Conrod^2./12.;
#-----------------------------------------------------------------------------
# References
reference: Ref_Conrod,
Length_Crank, 0., 0., # absolute position
euler, 0., 0., asin(Offset_Slider/Length_Conrod), # absolute orientation
null, # absolute velocity
null; # absolute angular velocity
#-----------------------------------------------------------------------------
# [Nodes Block]
begin: nodes;
#-----------------------------------------------------------------------------
# Nodes
structural: Node_Ground, static,
0., 0., 0., # absolute position
eye, # absolute orientation
null, # absolute velocity
null; # absolute angular velocity
structural: Node_Crank, dynamic,
Length_Crank/2., 0., 0., # absolute position
eye, # absolute orientation
null, # absolute velocity
null; # absolute angular velocity
structural: Node_Conrod, dynamic,
reference, Ref_Conrod, Length_Conrod/2., 0., 0., # absolute position
reference, Ref_Conrod, eye, # absolute orientation
null, # absolute velocity
null; # absolute angular velocity
structural: Node_Slider, dynamic,
reference, Ref_Conrod, Length_Conrod, 0., 0., # absolute position
eye, # absolute orientation
null, # absolute velocity
null; # absolute angular velocity
end: nodes;
#-----------------------------------------------------------------------------
# [Elements Block]
begin: elements;
#-----------------------------------------------------------------------------
# Bodies
body: Body_Crank, Node_Crank,
Mass_Crank, # mass
null, # relative center of mass
diag, 1., 1., Izz_Crank; # inertia matrix
body: Body_Conrod, Node_Conrod,
Mass_Conrod, # mass
null, # relative center of mass
diag, 1., 1., Izz_Conrod; # inertia matrix
body: Body_Slider, Node_Slider,
Mass_Slider, # mass
null, # relative center of mass
eye; # inertia matrix
#-----------------------------------------------------------------------------
# Joints
joint: JoClamp_Ground,
clamp,
Node_Ground,
null, # absolute position
eye; # absolute orientation
joint: JoAxrot_Ground_Crank,
axial rotation,
Node_Ground,
null, # relative offset
hinge, eye, # relative orientation
Node_Crank,
-Length_Crank/2., 0., 0., # relative offset
hinge, eye, # relative orientation
ramp, 2.*pi, 0., 1., 0.; # angular velocity
joint: JoRevh_Crank_Conrod,
revolute hinge,
Node_Crank,
reference, Ref_Conrod, null, # relative offset
hinge, reference, Ref_Conrod, eye, # relative axis orientation
Node_Conrod,
reference, Ref_Conrod, null, # relative offset
hinge, reference, Ref_Conrod, eye; # relative axis orientation
joint: JoInlin_Conrod_Slider,
in line,
Node_Conrod,
Length_Conrod/2., 0., 0., # relative line position
eye, # relative orientation
Node_Slider;
joint: JoInlin_Ground_Slider,
in line,
Node_Ground,
0., Offset_Slider, 0., # relative line position
1, 0., 0., -1., 3, 1., 0., 0., # relative orientation
Node_Slider;
joint: JoPrism_Ground_Slider,
prismatic,
Node_Ground,
Node_Slider;
end: elements;