feat(newton): first newton solver implementation
This commit is contained in:
@@ -141,55 +141,50 @@ TEST_CASE(
|
||||
tags::model_specification_type_contract
|
||||
) {
|
||||
using namespace mean_field;
|
||||
using Request = models::FixedAngularMomentumLayoutRequest;
|
||||
using Form = operators::CompiledStellarEquilibriumForm<AngularMomentumPolytropicMassModel>;
|
||||
using Jacobian = operators::CompiledStellarEquilibriumJacobianForm<AngularMomentumPolytropicMassModel>;
|
||||
using AngularValue = utils::blocks::fixed_angular_momentum::angular_velocity::value;
|
||||
using Request = models::FixedAngularMomentumLayoutRequest;
|
||||
using Form = operators::CompiledStellarEquilibriumForm<AngularMomentumPolytropicMassModel>;
|
||||
using Jacobian = operators::CompiledStellarEquilibriumJacobianForm<AngularMomentumPolytropicMassModel>;
|
||||
using AngularValue = utils::blocks::fixed_angular_momentum::angular_velocity::value;
|
||||
using AngularResidual = utils::blocks::fixed_angular_momentum::angular_velocity::residual;
|
||||
|
||||
STATIC_CHECK(models::ConstraintLayoutRequestType<Request>);
|
||||
STATIC_CHECK(models::CompiledConstraint<models::CompiledFixedAngularMomentum>);
|
||||
STATIC_CHECK(std::same_as<
|
||||
typename Request::GeneratedValueType,
|
||||
models::PhysicalCoordinateFor<models::FixedAngularMomentum>>);
|
||||
STATIC_CHECK(std::same_as<
|
||||
typename AngularValue::GeneratedType,
|
||||
models::PhysicalCoordinateFor<models::FixedAngularMomentum>>);
|
||||
STATIC_CHECK(std::same_as<
|
||||
typename models::CompiledFixedAngularMomentum::AngularVelocityField,
|
||||
field::AngularVelocity>);
|
||||
STATIC_CHECK(
|
||||
std::same_as<typename Request::GeneratedValueType, models::PhysicalCoordinateFor<models::FixedAngularMomentum>>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
std::same_as<typename AngularValue::GeneratedType, models::PhysicalCoordinateFor<models::FixedAngularMomentum>>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
std::same_as<typename models::CompiledFixedAngularMomentum::AngularVelocityField, field::AngularVelocity>
|
||||
);
|
||||
STATIC_CHECK(Form::value_block_count == 7);
|
||||
STATIC_CHECK(Form::residual_block_count == 7);
|
||||
STATIC_CHECK(Request::valueBlock<Form>().index == 6);
|
||||
STATIC_CHECK(Request::residualBlock<Form>().index == 6);
|
||||
STATIC_CHECK(utils::blocks::valid_jacobian_form<Form, Jacobian>);
|
||||
STATIC_CHECK(utils::blocks::has_jacobian_coupling_v<
|
||||
AngularResidual,
|
||||
utils::blocks::density::mass::value,
|
||||
Jacobian>);
|
||||
STATIC_CHECK(utils::blocks::has_jacobian_coupling_v<
|
||||
AngularResidual,
|
||||
utils::blocks::surface_deformation::parameters::value,
|
||||
Jacobian>);
|
||||
STATIC_CHECK(
|
||||
utils::blocks::has_jacobian_coupling_v<AngularResidual, utils::blocks::density::mass::value, Jacobian>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
utils::blocks::has_jacobian_coupling_v<
|
||||
AngularResidual, utils::blocks::surface_deformation::parameters::value, Jacobian>
|
||||
);
|
||||
STATIC_CHECK(utils::blocks::has_jacobian_coupling_v<AngularResidual, AngularValue, Jacobian>);
|
||||
STATIC_CHECK(utils::blocks::has_jacobian_coupling_v<
|
||||
utils::blocks::surface_deformation::shape_equilibrium::residual,
|
||||
AngularValue,
|
||||
Jacobian>);
|
||||
STATIC_CHECK(utils::blocks::has_jacobian_coupling_v<
|
||||
utils::blocks::enthalpy::specific::residual,
|
||||
AngularValue,
|
||||
Jacobian>);
|
||||
STATIC_CHECK_FALSE(utils::blocks::has_jacobian_coupling_v<
|
||||
utils::blocks::gravity::poisson::residual,
|
||||
AngularValue,
|
||||
Jacobian>);
|
||||
STATIC_CHECK(
|
||||
utils::blocks::has_jacobian_coupling_v<
|
||||
utils::blocks::surface_deformation::shape_equilibrium::residual, AngularValue, Jacobian>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
utils::blocks::has_jacobian_coupling_v<utils::blocks::enthalpy::specific::residual, AngularValue, Jacobian>
|
||||
);
|
||||
STATIC_CHECK_FALSE(
|
||||
utils::blocks::has_jacobian_coupling_v<utils::blocks::gravity::poisson::residual, AngularValue, Jacobian>
|
||||
);
|
||||
|
||||
const integral::FixedAngularMomentum specification({
|
||||
.Jtotal = dimensions::AngularMomentumValue{2.75},
|
||||
.axis = {0.0, 3.0, 4.0},
|
||||
.center = {0.25, -0.5, 0.75}
|
||||
});
|
||||
const integral::FixedAngularMomentum specification(
|
||||
{.Jtotal = dimensions::AngularMomentumValue{2.75}, .axis = {0.0, 3.0, 4.0}, .center = {0.25, -0.5, 0.75}}
|
||||
);
|
||||
const models::CompiledFixedAngularMomentum compiled = models::compileConstraint(specification);
|
||||
CHECK(compiled.targetAngularMomentum() == dimensions::AngularMomentumValue{2.75});
|
||||
CHECK(std::abs(compiled.specification().axis()[0]) < 1.0e-15);
|
||||
@@ -281,9 +276,7 @@ TEST_CASE(
|
||||
) {
|
||||
const mean_field::models::FixedTotalMass mass{mean_field::dimensions::MassValue{1.25}};
|
||||
const mean_field::models::FixedCentralDensity centralDensity{mean_field::eos::DensityValue{2.5}};
|
||||
const mean_field::models::FixedAngularMomentum angularMomentum{
|
||||
mean_field::dimensions::AngularMomentumValue{0.75}
|
||||
};
|
||||
const mean_field::models::FixedAngularMomentum angularMomentum{mean_field::dimensions::AngularMomentumValue{0.75}};
|
||||
|
||||
CHECK(mass.targetMass() == mean_field::dimensions::MassValue{1.25});
|
||||
CHECK(centralDensity.targetDensity() == mean_field::eos::DensityValue{2.5});
|
||||
@@ -308,18 +301,17 @@ TEST_CASE(
|
||||
std::invalid_argument
|
||||
);
|
||||
CHECK_THROWS_AS(
|
||||
mean_field::models::FixedAngularMomentum({
|
||||
.Jtotal = mean_field::dimensions::AngularMomentumValue{1.0},
|
||||
.axis = {0.0, 0.0, 0.0}
|
||||
}),
|
||||
mean_field::models::FixedAngularMomentum(
|
||||
{.Jtotal = mean_field::dimensions::AngularMomentumValue{1.0}, .axis = {0.0, 0.0, 0.0}}
|
||||
),
|
||||
std::invalid_argument
|
||||
);
|
||||
CHECK_THROWS_AS(
|
||||
mean_field::models::FixedAngularMomentum({
|
||||
.Jtotal = mean_field::dimensions::AngularMomentumValue{1.0},
|
||||
.axis = {0.0, 0.0, 1.0},
|
||||
.center = {0.0, std::numeric_limits<double>::quiet_NaN(), 0.0}
|
||||
}),
|
||||
mean_field::models::FixedAngularMomentum(
|
||||
{.Jtotal = mean_field::dimensions::AngularMomentumValue{1.0},
|
||||
.axis = {0.0, 0.0, 1.0},
|
||||
.center = {0.0, std::numeric_limits<double>::quiet_NaN(), 0.0}}
|
||||
),
|
||||
std::invalid_argument
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user