Skip to content

Commit 160b2c0

Browse files
committed
[#1359] Add setters for initial spacecraft potentials
1 parent 71cb976 commit 160b2c0

4 files changed

Lines changed: 66 additions & 12 deletions

File tree

src/simulation/environment/spacecraftChargingDynamics/_UnitTest/test_spacecraftChargingDynamics.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
temp_photons = 2.0 # [eV] Photoelectron temperature
3535
flux_photons = 1e-6 # [A/m^2] Photoelectron flux
3636

37+
@pytest.mark.parametrize(
38+
("servicer_potential_init", "target_potential_init"), # ([Volts], [Volts])
39+
[
40+
(0.0, 0.0),
41+
(-5000.0, -5000.0), # GEO eclipse
42+
(10.0, 10.0), # GEO sunlit
43+
(11000.0, 0.0) # Electron beam should not reach target
44+
]
45+
)
3746
@pytest.mark.parametrize(
3847
("servicer_radius", "target_radius"), # ([m], [m])
3948
[
@@ -47,6 +56,8 @@
4756
@pytest.mark.parametrize("electron_beam_current", [0.0, 0.001, 250e-6]) # [Amps]
4857
@pytest.mark.parametrize("electron_beam_alpha", [0.0, 0.5, 1.0]) # [-]
4958
def test_spacecraft_charging_dynamics(show_plots,
59+
servicer_potential_init,
60+
target_potential_init,
5061
servicer_radius,
5162
target_radius,
5263
bulk_velocity_ions,
@@ -69,6 +80,8 @@ def test_spacecraft_charging_dynamics(show_plots,
6980
**Test Parameters**
7081
7182
Args:
83+
servicer_potential_init (float): [Volts] Servicer initial potential
84+
target_potential_init (float): [Volts] Target initial potential
7285
servicer_radius (float): [m] Servicer spacecraft radius
7386
target_radius (float): [m] Target spacecraft radius
7487
bulk_velocity_ions (float): [m/s] Bulk velocity of plasma ions
@@ -85,7 +98,7 @@ def test_spacecraft_charging_dynamics(show_plots,
8598
task_name = "unitTask"
8699
process_name = "TestProcess"
87100
sim = SimulationBaseClass.SimBaseClass()
88-
test_time_step_sec = 1e-6
101+
test_time_step_sec = 1e-7
89102
test_process_rate = macros.sec2nano(test_time_step_sec)
90103
test_process = sim.CreateNewProcess(process_name)
91104
test_process.addTask(sim.CreateNewTask(task_name, test_process_rate))
@@ -161,6 +174,8 @@ def test_spacecraft_charging_dynamics(show_plots,
161174
capacitance = 1e-9 # [farads]
162175
spacecraft_charging = spacecraftChargingDynamics.SpacecraftChargingDynamics()
163176
spacecraft_charging.ModelTag = "SpacecraftChargingDynamics"
177+
spacecraft_charging.setServicerPotentialInit(servicer_potential_init)
178+
spacecraft_charging.setTargetPotentialInit(target_potential_init)
164179
spacecraft_charging.setServicerCapacitance(capacitance)
165180
spacecraft_charging.setTargetCapacitance(capacitance)
166181
spacecraft_charging.setFluxPhotoelectrons(flux_photons)
@@ -207,7 +222,7 @@ def test_spacecraft_charging_dynamics(show_plots,
207222

208223
# Run the simulation
209224
sim.InitializeSimulation()
210-
sim_time = 0.0001 # [s]
225+
sim_time = 0.00001 # [s]
211226
sim.ConfigureStopTime(macros.sec2nano(sim_time))
212227
sim.ExecuteSimulation()
213228

@@ -272,8 +287,8 @@ def test_spacecraft_charging_dynamics(show_plots,
272287
target_electron_beam_current_list_truth.append(target_electron_beam_current)
273288

274289
# Compute servicer and target potential truth information
275-
servicer_potential_list_truth = [0.0]
276-
target_potential_list_truth = [0.0]
290+
servicer_potential_list_truth = [servicer_potential_init]
291+
target_potential_list_truth = [target_potential_init]
277292
for idx in range(len(timespan)-1):
278293
servicer_potential = servicer_potential_list_sim[idx]
279294
target_potential = target_potential_list_sim[idx]
@@ -551,6 +566,8 @@ def compute_electron_beam_current(electron_beam_current,
551566
if __name__ == "__main__":
552567
test_spacecraft_charging_dynamics(
553568
False, # show_plots
569+
0.0, # [Volts]
570+
0.0, # [Volts]
554571
4.0, # [m]
555572
2.0, # [m]
556573
400000.0, # [m/s]

src/simulation/environment/spacecraftChargingDynamics/spacecraftChargingDynamics.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,34 @@ void SpacecraftChargingDynamics::postIntegration(uint64_t integrateToThisTimeNan
323323
this->timeBefore = integrateToThisTimeNanos*NANO2SEC;
324324
}
325325

326+
/*! Setter for the initial servicer potential.
327+
@param potentialInit [Volts] Servicer initial potential
328+
*/
329+
void SpacecraftChargingDynamics::setServicerPotentialInit(const double potentialInit) {
330+
this->servicerPotentialInit = potentialInit;
331+
}
332+
333+
/*! Setter for the initial target potential.
334+
@param potentialInit [Volts] Target initial potential
335+
*/
336+
void SpacecraftChargingDynamics::setTargetPotentialInit(const double potentialInit) {
337+
this->targetPotentialInit = potentialInit;
338+
}
339+
340+
/*! Getter for the servicer initial potential.
341+
@return double
342+
*/
343+
double SpacecraftChargingDynamics::getServicerPotentialInit() const {
344+
return this->servicerPotentialInit;
345+
}
346+
347+
/*! Getter for the target initial potential.
348+
@return double
349+
*/
350+
double SpacecraftChargingDynamics::getTargetPotentialInit() const {
351+
return this->targetPotentialInit;
352+
}
353+
326354
/*! Setter for the servicer spacecraft capacitance.
327355
@param capacitance [farad] Servicer spacecraft capacitance
328356
*/

src/simulation/environment/spacecraftChargingDynamics/spacecraftChargingDynamics.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class SpacecraftChargingDynamics : public DynamicObject{
4747
void preIntegration(uint64_t callTimeNanos) final; //!< Pre-integration method
4848
void postIntegration(uint64_t callTimeNanos) final; //!< Post-integration method
4949

50+
void setServicerPotentialInit(const double potentialInit); //!< Setter for the initial servicer potential
51+
void setTargetPotentialInit(const double potentialInit); //!< Setter for the initial target potential
52+
double getServicerPotentialInit() const; //!< Getter for the initial servicer potential
53+
double getTargetPotentialInit() const; //!< Getter for the initial target potential
5054
void setServicerCapacitance(const double capacitance); //!< Setter for the servicer capacitance
5155
void setTargetCapacitance(const double capacitance); //!< Setter for the target capacitance
5256
double getServicerCapacitance() const; //!< Getter for the servicer capacitance
@@ -91,10 +95,10 @@ class SpacecraftChargingDynamics : public DynamicObject{
9195
BSKLogger bskLogger; //!< BSK Logging
9296

9397
private:
94-
double servicerCapacitance{1e-9}; //!< [farads] Servicer capacitance
95-
double targetCapacitance{1e-9}; //!< [farads] Target capacitance
9698
double servicerPotentialInit{}; //!< [Volts] Initial servicer potential
9799
double targetPotentialInit{}; //!< [Volts] Initial target potential
100+
double servicerCapacitance{1e-9}; //!< [farads] Servicer capacitance
101+
double targetCapacitance{1e-9}; //!< [farads] Target capacitance
98102
double servicerSurfaceArea{}; //!< [m^2] Servicer surface area
99103
double targetSurfaceArea{}; //!< [m^2] Target surface area
100104
double servicerSunlitArea{}; //!< [m^2] Servicer sunlit area

src/simulation/environment/spacecraftChargingDynamics/spacecraftChargingDynamics.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ electric potential of two spacecraft (a servicer and a target) in a plasma envir
55
ordinary differential equation for each spacecraft. The charging model includes plasma electron current, plasma
66
ion current, photoelectric current, and an optional electron beam current.
77

8+
.. note::
9+
while this module defaults all module member variables, there is a setter method available for each attribute.
10+
811
Message Connection Descriptions
912
-------------------------------
1013
The following table lists all module input and output messages.
@@ -58,7 +61,7 @@ See the following journal paper for a detailed description of the charging equat
5861

5962
.. note::
6063

61-
C. Hammerl and H. Schaub, `“Servicing and Target Spacecraft Charging Behavior Due to Emission of an
64+
J. Hammerl and H. Schaub, `“Servicing and Target Spacecraft Charging Behavior Due to Emission of an
6265
Electron Beam” <https://hanspeterschaub.info/PapersPrivate/Hammerl2024a.pdf>`_.
6366

6467
The module computes the total current on each spacecraft as the sum of:
@@ -101,9 +104,9 @@ correctly computes the photoelectric current, electron beam current, plasma elec
101104
current acting on both spacecraft. While the module defaults many required variables, the user has the ability
102105
to configure all information describing the electrons, ions, and photons using setter methods.
103106

104-
The test varies the servicer and target size, the electron beam parameters, and the bulk plasma ion velocity. The test
105-
checks that the module correctly computes the photoelectric current, electron beam current, plasma electron current,
106-
and plasma ion current acting on both spacecraft.
107+
The test varies the initial spacecraft potentials and sizes, the electron beam parameters, and the bulk plasma ion
108+
velocity. The test checks that the module correctly computes the photoelectric current, electron beam current,
109+
plasma electron current, and plasma ion current acting on both spacecraft.
107110

108111
User Guide
109112
----------
@@ -191,8 +194,10 @@ The following steps are required to set up the ``spacecraftChargingDynamics`` mo
191194
capacitance = 1e-9 # [F]
192195
charging_dynamics = spacecraftChargingDynamics.SpacecraftChargingDynamics()
193196
charging_dynamics.ModelTag = "SpacecraftChargingDynamics"
194-
charging_dynamics.setServicerCapacitance(capacitance)
195-
charging_dynamics.setTargetCapacitance(capacitance)
197+
charging_dynamics.setServicerPotentialInit(0.0) # [Volts]
198+
charging_dynamics.setTargetPotentialInit(0.0) # [Volts]
199+
charging_dynamics.setServicerCapacitance(capacitance) # [farads]
200+
charging_dynamics.setTargetCapacitance(capacitance) # [farads]
196201

197202
charging_dynamics.setTempPhotoelectrons(2.0) # [eV]
198203
charging_dynamics.setFluxPhotoelectrons(1e-6) # [A/m^2]

0 commit comments

Comments
 (0)