Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virial stress #137

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
594f5cb
added virial stress variable to lines 372 and 374 (const). Adjusted l…
kinanbezem7 Oct 16, 2024
45641a9
added virial stress calculation to energy_full in force_PMB
kinanbezem7 Oct 16, 2024
a1c497a
Corrected errors in build, unsure about bond breakage criteria in the…
kinanbezem7 Oct 17, 2024
db419fb
Corrected particles.hpp which was causing NaNs in the output
kinanbezem7 Oct 17, 2024
112b5cb
output virial stress
kinanbezem7 Oct 17, 2024
c3c6c9f
cleaned up previous runs from repo
kinanbezem7 Oct 17, 2024
8cfbe4e
Moved slices outside of kernel and adjust virial stress calculations …
kinanbezem7 Oct 18, 2024
3ab38ff
fixup: format
streeve Oct 18, 2024
d5f327b
fixup: remove const on particles
streeve Oct 18, 2024
a6a3a49
Remove .vscode directory from repository
kinanbezem7 Oct 18, 2024
108f53c
Made suggested formatting changes and virial stress is now working fo…
kinanbezem7 Oct 18, 2024
75e8fbc
Virial stress added for PMB fracture problem.
kinanbezem7 Oct 22, 2024
74e5511
Applied clang-format changes to CabanaPD_Particles.hpp and Force_PMB.hpp
kinanbezem7 Oct 24, 2024
493bc3f
Changed the claculation of the stress tensor using a new reference
pabloseleson Nov 19, 2024
b63fc69
Revised commment
pabloseleson Nov 19, 2024
46d28ea
Changed stress computation adding all 9 components due to lack of sym…
pabloseleson Nov 21, 2024
bd6311d
Merge branch 'main' into virialStress
streeve Nov 21, 2024
d7d869c
Make energy/stress optional in particle lists
streeve Nov 21, 2024
d1ad096
Fixed stress dimension
pabloseleson Nov 22, 2024
3e054ef
Added stress calculation to linear PMB model
pabloseleson Nov 22, 2024
8de53b6
Finish optional energy/stress
streeve Nov 22, 2024
66ea5ad
Merge branch 'main' into virialStress
streeve Dec 4, 2024
090317e
Merge branch 'virialStress' into virialStress
streeve Dec 4, 2024
982bcec
fixup: compute free functions
streeve Dec 4, 2024
c5a598c
fixup: remove linear pmb stress
streeve Dec 4, 2024
c41e88e
Revert unneeded changes
streeve Dec 9, 2024
aef9d08
Fixed return error on stress function
kinanbezem7 Dec 18, 2024
948439e
New example file for testing stress
kinanbezem7 Dec 19, 2024
6197b95
added stress to linear PMB
kinanbezem7 Dec 19, 2024
a118af4
corrected linearized distance
kinanbezem7 Dec 20, 2024
fb87332
Added stress to LPS (not tested)
kinanbezem7 Dec 20, 2024
72469c4
format
kinanbezem7 Dec 20, 2024
a77540c
fixup: LPS stress compilation
streeve Dec 30, 2024
18db77c
Merge branch 'main' into virialStress
streeve Dec 30, 2024
0247acf
fixup merge: use local size member functions, prenotch in init
streeve Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
build/
*.out
*.silo
run/
25 changes: 25 additions & 0 deletions .vscode/settings.json
kinanbezem7 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"files.associations": {
"array": "cpp",
"chrono": "cpp",
"cwchar": "cpp",
"forward_list": "cpp",
"vector": "cpp",
"exception": "cpp",
"fstream": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"new": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"valarray": "cpp"
}
}
32 changes: 22 additions & 10 deletions src/CabanaPD_Particles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Particles<MemorySpace, PMB, TemperatureIndependent, Dimension>
using int_type = Cabana::MemberTypes<int>;
// v, W, rho, damage, type.
using other_types =
Cabana::MemberTypes<double[dim], double, double, double, int>;
Cabana::MemberTypes<double[dim * 2],double[dim], double, double, double, int>; //added double[dim * 2] for virial stress
kinanbezem7 marked this conversation as resolved.
Show resolved Hide resolved
// Potentially needed later: body force (b), ID.

// FIXME: add vector length.
Expand Down Expand Up @@ -344,6 +344,9 @@ class Particles<MemorySpace, PMB, TemperatureIndependent, Dimension>
return Cabana::slice<0>( _aosoa_u, "displacements" );
}
auto sliceForce() { return _plist_f.slice( CabanaPD::Field::Force() ); }

auto sliceForce() const { return _plist_f.slice( CabanaPD::Field::Force() ); } //added const version for slicing in energy calculation

auto sliceForceAtomic()
{
auto f = sliceForce();
Expand All @@ -361,29 +364,38 @@ class Particles<MemorySpace, PMB, TemperatureIndependent, Dimension>
auto sliceType() const { return Cabana::slice<4>( _aosoa_other, "type" ); }
auto sliceStrainEnergy()
{
return Cabana::slice<1>( _aosoa_other, "strain_energy" );
return Cabana::slice<2>( _aosoa_other, "strain_energy" );
}
auto sliceStrainEnergy() const
{
return Cabana::slice<1>( _aosoa_other, "strain_energy" );
return Cabana::slice<2>( _aosoa_other, "strain_energy" );
}
auto sliceVirialStress()
{
return Cabana::slice<0>(_aosoa_other, "virial_stress"); //added virial stress
}
auto sliceVirialStress() const
{
return Cabana::slice<0>(_aosoa_other, "virial_stress"); //added virial stress const
}

auto sliceVelocity()
{
return Cabana::slice<0>( _aosoa_other, "velocities" );
return Cabana::slice<1>( _aosoa_other, "velocities" );
}
auto sliceVelocity() const
{
return Cabana::slice<0>( _aosoa_other, "velocities" );
return Cabana::slice<1>( _aosoa_other, "velocities" );
}
auto sliceDensity() { return Cabana::slice<2>( _aosoa_other, "density" ); }
auto sliceDensity() { return Cabana::slice<3>( _aosoa_other, "density" ); }
auto sliceDensity() const
{
return Cabana::slice<2>( _aosoa_other, "density" );
return Cabana::slice<3>( _aosoa_other, "density" );
}
auto sliceDamage() { return Cabana::slice<3>( _aosoa_other, "damage" ); }
auto sliceDamage() { return Cabana::slice<4>( _aosoa_other, "damage" ); }
auto sliceDamage() const
{
return Cabana::slice<3>( _aosoa_other, "damage" );
return Cabana::slice<4>( _aosoa_other, "damage" );
}
auto sliceNoFail()
{
Expand Down Expand Up @@ -450,7 +462,7 @@ class Particles<MemorySpace, PMB, TemperatureIndependent, Dimension>
Cabana::Experimental::HDF5ParticleOutput::writeTimeStep(
h5_config, "particles", MPI_COMM_WORLD, output_step, output_time,
n_local, getPosition( use_reference ), sliceStrainEnergy(),
sliceForce(), sliceDisplacement(), sliceVelocity(), sliceDamage() );
sliceForce(), sliceDisplacement(), sliceVelocity(), sliceDamage(), sliceVirialStress() );
#else
#ifdef Cabana_ENABLE_SILO
Cabana::Grid::Experimental::SiloParticleOutput::
Expand Down
19 changes: 18 additions & 1 deletion src/force/CabanaPD_Force_PMB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ class Force<ExecutionSpace, ForceModel<PMB, Elastic, ModelParams...>>

auto model = _model;
const auto vol = particles.sliceVolume();
auto virial_stress = particles.sliceVirialStress(); // Moved outside of kernel
const auto f = particles.sliceForce(); //Slice forces outside of Kernel


auto energy_full =
KOKKOS_LAMBDA( const int i, const int j, double& Phi )
{
// Get the bond distance, displacement, and stretch.
double xi, r, s;
getDistance( x, u, i, j, xi, r, s );
double rx, ry, rz;
getDistanceComponents( x, u, i, j, xi, r, s, rx, ry, rz );

model.thermalStretch( s, i, j );

Expand All @@ -161,6 +165,19 @@ class Force<ExecutionSpace, ForceModel<PMB, Elastic, ModelParams...>>
double w = 0.25 * model.c * s * s * xi * vol( j );
W( i ) += w;
Phi += w * vol( i );



// Use precomputed force for virial stress
virial_stress(i, 0) += (rx * f(i, 0)) / vol( j ); // σ_xx
virial_stress(i, 1) += (ry * f(i, 1)) / vol( j ); // σ_yy
virial_stress(i, 2) += (rz * f(i, 2)) / vol( j ); // σ_zz

virial_stress(i, 3) += (rx * f(i, 1)) / vol( j ); // σ_xy
virial_stress(i, 4) += (rx * f(i, 2)) / vol( j ); // σ_xz
virial_stress(i, 5) += (ry * f(i, 2)) / vol( j ); // σ_yz


};

double strain_energy = 0.0;
Expand Down