Skip to content

Commit 94dd02f

Browse files
Merge pull request #145 from EXP-code/cylheight
Improve scale height consistency
2 parents 3bb752d + 90aec55 commit 94dd02f

55 files changed

Lines changed: 5363 additions & 1110 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25) # Needed for CUDA, MPI, and CTest features
22

33
project(
44
EXP
5-
VERSION "7.8.6"
5+
VERSION "7.9.1"
66
HOMEPAGE_URL https://github.com/EXP-code/EXP
77
LANGUAGES C CXX Fortran)
88

@@ -268,7 +268,13 @@ endif()
268268
# try to find pybind11 and build wrapper python module
269269
find_package(Python3 COMPONENTS Interpreter Development)
270270
message(STATUS "python3 include dirs: ${Python3_INCLUDE_DIRS}")
271-
271+
if(Python3_FOUND)
272+
set(HAVE_PYTHON3 TRUE)
273+
else()
274+
if(ENABLE_PYEXP)
275+
message(FATAL_ERROR "You asked for pyEXP but I cannot find a Python3 environment. Please make Python3 available or disable pyEXP. CMake will exit." )
276+
endif()
277+
endif()
272278

273279
# Force installation of the yaml-cpp libraries
274280
install(TARGETS yaml-cpp DESTINATION lib)

config_cmake.h_in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
/* Defined if you have HDF5 support */
2020
#cmakedefine HAVE_HDF5 @HAVE_HDF5@
2121

22+
/* Defined if Python3 runtime exists */
23+
#cmakedefine HAVE_PYTHON3 1
24+
2225
/* Define to 1 if you have the `cuda' library. */
2326
#cmakedefine HAVE_LIBCUDA 1
2427

doc/exp.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = EXP
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = 7.8.0
51+
PROJECT_NUMBER = 7.9.1
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

expui/BasisFactory.H

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ namespace BasisClasses
137137
Eigen::Vector3d currentAccel(double time);
138138

139139
public:
140+
140141
//! The current pseudo acceleration
141142
Eigen::Vector3d pseudo {0, 0, 0};
142143

@@ -249,8 +250,8 @@ namespace BasisClasses
249250

250251
//@{
251252
//! Initialize non-inertial forces
252-
void setNonInertial(int N, Eigen::VectorXd& x, Eigen::MatrixXd& pos);
253-
void setNonInertial(int N, const std::string& orient);
253+
void setNonInertial(int Naccel, const Eigen::VectorXd& x, const Eigen::MatrixXd& pos);
254+
void setNonInertial(int Naccel, const std::string& orient);
254255
//@}
255256

256257
//! Set the current pseudo acceleration
@@ -259,6 +260,16 @@ namespace BasisClasses
259260
if (Naccel > 0) pseudo = currentAccel(time);
260261
}
261262

263+
//! Returns true if non-inertial forces are active
264+
bool usingNonInertial() { return Naccel > 0; }
265+
266+
//! Reset to inertial coordinates
267+
void setInertial()
268+
{
269+
Naccel = 0;
270+
pseudo = {0, 0, 0};
271+
}
272+
262273
//! Get the field label vector
263274
std::vector<std::string> getFieldLabels(void)
264275
{ return getFieldLabels(coordinates); }

expui/BasisFactory.cc

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,16 @@ namespace BasisClasses
283283
return makeFromArray(time);
284284
}
285285

286-
void Basis::setNonInertial(int N, Eigen::VectorXd& t, Eigen::MatrixXd& pos)
286+
void Basis::setNonInertial(int N, const Eigen::VectorXd& t, const Eigen::MatrixXd& pos)
287287
{
288+
// Sanity checks
289+
if (t.size() < 1)
290+
throw std::runtime_error("Basis: setNonInertial: no times in time array");
291+
292+
if (t.size() != pos.rows())
293+
throw std::runtime_error("Basis::setNonInertial: size mismatch in time and position arrays");
294+
295+
// Set the data
288296
Naccel = N;
289297
t_accel = t;
290298
p_accel = pos;
@@ -351,16 +359,31 @@ namespace BasisClasses
351359
{
352360
Eigen::Vector3d ret;
353361

354-
if (time < t_accel(0) || time > t_accel(t_accel.size()-1)) {
355-
std::cout << "ERROR: " << time << " is outside of range of the non-inertial DB"
356-
<< std::endl;
357-
ret.setZero();
358-
return ret;
362+
auto n = t_accel.size();
363+
364+
// Allow a little bit of buffer in the allowable on-grid range but
365+
// otherwise force termination
366+
//
367+
if ( time < t_accel(0 ) - 0.5*(t_accel(1 ) - t_accel(0 )) ||
368+
time > t_accel(n-1) + 0.5*(t_accel(n-1) - t_accel(n-2)) ) {
369+
370+
std::ostringstream msg;
371+
msg << "Basis::currentAccel: " << time
372+
<< " is outside the range of the non-inertial DB ["
373+
<< t_accel(0) << ", " << t_accel(n-1) << "]";
374+
375+
throw std::runtime_error(msg.str());
359376
}
377+
// Do the quadratic interpolation
378+
//
360379
else {
361380
int imin = 0;
362-
int imax = std::lower_bound(t_accel.data(), t_accel.data()+t_accel.size(), time) - t_accel.data();
363-
if (imax > Naccel) imin = imax - Naccel;
381+
int imax = std::lower_bound(t_accel.data(), t_accel.data()+n, time) - t_accel.data();
382+
383+
// Get a range around the current time of approx size Naccel
384+
//
385+
imax = std::min<int>(n-1, imax + Naccel/2);
386+
imin = std::max<int>(imax - Naccel, 0);
364387

365388
int num = imax - imin + 1;
366389
Eigen::VectorXd t(num);

expui/BiorthBasis.H

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ namespace BasisClasses
163163

164164
//! Clear the particle selector callback
165165
void clrSelector() { ftor = nullptr; }
166+
167+
//! Evaluate acceleration in Cartesian coordinates in centered
168+
//! coordinate system
169+
virtual std::vector<double> getAccel(double x, double y, double z) = 0;
166170
};
167171

168172
/**
@@ -303,10 +307,14 @@ namespace BasisClasses
303307
{
304308
auto [ret, worst, lworst] = orthoCompute(orthoCheck(knots));
305309
// For the CTest log
306-
std::cout << "---- Spherical::orthoTest: worst=" << worst << std::endl;
310+
if (myid==0)
311+
std::cout << "---- Spherical::orthoTest: worst=" << worst << std::endl;
307312
return ret;
308313
}
309314

315+
//! Evaluate acceleration in Cartesian coordinates in centered
316+
//! coordinate system
317+
virtual std::vector<double> getAccel(double x, double y, double z);
310318
};
311319

312320
/**
@@ -538,10 +546,15 @@ namespace BasisClasses
538546
{
539547
auto [ret, worst, lworst] = orthoCompute(orthoCheck());
540548
// For the CTest log
541-
std::cout << "---- FlatDisk::orthoTest: worst=" << worst << std::endl;
549+
if (myid==0)
550+
std::cout << "---- FlatDisk::orthoTest: worst=" << worst << std::endl;
542551
return ret;
543552
}
544553

554+
//! Evaluate acceleration in Cartesian coordinates in centered
555+
//! coordinate system
556+
std::vector<double> getAccel(double x, double y, double z);
557+
545558
};
546559

547560
/**
@@ -689,10 +702,15 @@ namespace BasisClasses
689702
{
690703
auto [ret, worst, lworst] = orthoCompute(orthoCheck());
691704
// For the CTest log
692-
std::cout << "CBDisk::orthoTest: worst=" << worst << std::endl;
705+
if (myid==0)
706+
std::cout << "CBDisk::orthoTest: worst=" << worst << std::endl;
693707
return ret;
694708
}
695709

710+
//! Evaluate acceleration in Cartesian coordinates in centered
711+
//! coordinate system
712+
std::vector<double> getAccel(double x, double y, double z);
713+
696714
};
697715

698716
/**
@@ -718,7 +736,7 @@ namespace BasisClasses
718736
int rnum, pnum, tnum;
719737
double rmin, rmax, rcylmin, rcylmax;
720738
double acyl, hcyl;
721-
bool expcond, logarithmic, density, EVEN_M;
739+
bool expcond, logarithmic, density, EVEN_M, sech2 = false;
722740

723741
std::vector<Eigen::MatrixXd> potd, dpot, dpt2, dend;
724742
std::vector<Eigen::MatrixXd> legs, dlegs, d2legs;
@@ -842,9 +860,15 @@ namespace BasisClasses
842860
{
843861
auto [ret, worst, lworst] = orthoCompute(sl->orthoCheck());
844862
// For the CTest log
845-
std::cout << "---- Cylindrical::orthoTest: worst=" << worst << std::endl;
863+
if (myid==0)
864+
std::cout << "---- Cylindrical::orthoTest: worst=" << worst << std::endl;
846865
return ret;
847866
}
867+
868+
//! Evaluate acceleration in Cartesian coordinates in centered
869+
//! coordinate system
870+
std::vector<double> getAccel(double x, double y, double z);
871+
848872
};
849873

850874
/**
@@ -985,12 +1009,18 @@ namespace BasisClasses
9851009
}
9861010
}
9871011
}
988-
1012+
1013+
if (myid==0)
9891014
std::cout << "---- Slab::orthoTest: worst=" << worst << std::endl;
1015+
9901016
if (worst > __EXP__::orthoTol) return false;
9911017
return true;
9921018
}
9931019

1020+
//! Evaluate acceleration in Cartesian coordinates in centered
1021+
//! coordinate system
1022+
std::vector<double> getAccel(double x, double y, double z);
1023+
9941024
};
9951025

9961026
/**
@@ -1108,11 +1138,17 @@ namespace BasisClasses
11081138
}
11091139
}
11101140

1111-
std::cout << "---- Cube::orthoTest: worst=" << worst << std::endl;
1141+
if (myid==0)
1142+
std::cout << "---- Cube::orthoTest: worst=" << worst << std::endl;
1143+
11121144
if (worst > __EXP__::orthoTol) return false;
11131145
return true;
11141146
}
11151147

1148+
//! Evaluate acceleration in Cartesian coordinates in centered
1149+
//! coordinate system
1150+
std::vector<double> getAccel(double x, double y, double z);
1151+
11161152
};
11171153

11181154

0 commit comments

Comments
 (0)