Skip to content

Commit

Permalink
start testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rust404 committed Jul 26, 2020
1 parent 7560634 commit ebde372
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
16 changes: 9 additions & 7 deletions core.cpp
Expand Up @@ -31,6 +31,7 @@ double binarySearchGetPHI(double c,double a, double b,double thetaOne, double tr
return mid;
}
}
return left+(right-left)/2;
}
#endif

Expand All @@ -57,7 +58,7 @@ void nextDude(Dude& preDude,Dude& currentDude, uint32_t index, double depth,doub
double vertical=floatage-gravity;
double thetaOne = atan((vertical /horizontal));/* it's a radian */
double tractionOne = horizontal / cos(thetaOne);
#elif
#else
/* calculate */
double windForce = 0.625 * (BUOY_HEIGHT - depth) * 2 * BUOY_R * pow(WIND_SPEED, 2);
double floatage = SEA_WATER_DENSITY * G * depth * PHI * pow(BUOY_R, 2);
Expand All @@ -71,7 +72,7 @@ void nextDude(Dude& preDude,Dude& currentDude, uint32_t index, double depth,doub
currentDude._thetaTwo=thetaOne;
currentDude._tractionTwo=tractionOne;
currentDude._length=depth;
currentDude._phi=PHI/2;
currentDude._phi=PHI/2;
}

/* tube */
Expand Down Expand Up @@ -107,7 +108,7 @@ void nextDude(Dude& preDude,Dude& currentDude, uint32_t index, double depth,doub
double thetaTwo=atan(vertical/horizontal);
double tractionTwo=horizontal/cos(thetaTwo);

#elif
#else
/* calculate */
double thetaOne=preDude._thetaTwo;
double tractionOne=preDude._tractionTwo;
Expand Down Expand Up @@ -179,15 +180,16 @@ void nextDude(Dude& preDude,Dude& currentDude, uint32_t index, double depth,doub
double phi=binarySearchGetPHI(c,a,b,thetaOne,tractionOne);
double waterForceCylinder=b*sin(phi);

double vertical=thetaOne*sin(tractionOne)-
double vertical=tractionOne*sin(thetaOne)-
(gravityCyinder-floatageCylinder)-
ballVertical;

double horizontal=thetaOne*cos(thetaOne)+waterForceCylinder+ballHorizontal;

double horizontal=tractionOne*cos(thetaOne)+waterForceCylinder+ballHorizontal;
double thetaTwo=atan(vertical/horizontal);
double tractionTwo=vertical/sin(thetaTwo);

#elif
#else
/* calculate */
double thetaOne=preDude._thetaTwo;
double tractionOne=preDude._tractionTwo;
Expand Down Expand Up @@ -273,7 +275,7 @@ void nextDude(Dude& preDude,Dude& currentDude, uint32_t index, double depth,doub
double thetaTwo=atan(vertical/horizontal);
double tractionTwo=horizontal/cos(thetaTwo);

#elif
#else
/* calculate */
double thetaOne=preDude._thetaTwo;
double tractionOne=preDude._tractionTwo;
Expand Down
20 changes: 16 additions & 4 deletions main.cpp
Expand Up @@ -100,14 +100,26 @@ double binarySearchHammerMass(
int main()
{

Indicators currentIndicator;
double minMass=binarySearchHammerMass(1200,3000,DEFUALT_HAMMER_MASS_BIAS,currentIndicator);
/* Indicators currentIndicator;
double minMass=binarySearchHammerMass(1200,6000,DEFUALT_HAMMER_MASS_BIAS,currentIndicator);
std::cout<<"the minimum hammer mass: "<<minMass<<std::endl;
currentIndicator.display();
currentIndicator.display(); */

Indicators indi;
binarySearchImmersionDepth(18.0f,DEFUALT_BIAS,0.5,1.5,1200,indi); //dudes is here
binarySearchImmersionDepth(SEA_DEPTH,DEFUALT_BIAS,0.2f,10.0,3000,indi); //dudes is here
indi.display();


/* //unit test
std::vector<Dude> dudes;
Indicators indi;
OneTry(dudes,0.7,1200);
for(int i=0;i<dudes.size();++i){
dudes[i].display();
}
oneValidation(dudes,indi);
indi.display(); */


return 0;
}
14 changes: 7 additions & 7 deletions para.h
Expand Up @@ -25,18 +25,19 @@

// chain
#define TOTAL_LENGTH 22.05 /* m */
#define UNIT_LENGTH 0.105 /* m */
#define UNIT_MASS 7 /* kg/m */
#define UNIT_LENGTH 0.50 /* m */
#define UNIT_MASS 19.5 /* kg/m */
#define CHAIN_DENSITY 7800 /* kg/m3 */
#define TOTAL_COUNT (22.05/0.105)
#define TOTAL_COUNT (TOTAL_LENGTH/UNIT_LENGTH)

// iron ball (hammer)
#define HAMMER_MASS 1200 /* kg */
#define HAMMER_MASS 1200
/* kg */
#define HAMMER_DENSITY 7800 /* kg/m3 */


// nature
#define WIND_SPEED 24 /* m */
#define WIND_SPEED 36 /* m */
#define WATER_SPEED 1.5 /* m */
#define SEA_DEPTH 18 /* m */
#define SEA_WATER_DENSITY 1025 /* kg/m3 */
Expand All @@ -50,6 +51,7 @@
// precise level
#define DEFUALT_BIAS 0.0005 /* 0-1 */
#define DEFUALT_HAMMER_MASS_BIAS 5 /* kg */
#define PHI_BIAS 0.001

// config
#define CHAIN_SHAPE_FILE "./chainShape.txt"
Expand All @@ -58,6 +60,4 @@
#define SEA_FORCE




#endif //PARA_H
Binary file modified test
Binary file not shown.

0 comments on commit ebde372

Please sign in to comment.