def _initialize_dipole_model(self, model): """Initializes dipole Model. This method uses the simplified dipole model implemented in DipoleModel.py Which needs to initialize the induced Magnetic density in the hysteresis rods. It also adds the hysteresis rods and bar magnets specified in the settings file to the satellite using the DipoleModel class. Args: model: dictionary holding information about hysteresis rods and bar magnets of the satellite """ for key, hyst in model['Hysteresis'].items(): direction = np.array([float(x) for x in hyst['dir'].split(" ")]) self.dipoleM.addHysteresis(direction, hyst['vol'], hyst['Hc'], hyst['Bs'], hyst['Br']) # initialize values for Hysteresis (need B-field @ initial position) spacecraft_state = self.state_observer.spacecraftState self.inertial2Sat = spacecraft_state.getAttitude().getRotation() self.satPos_i = spacecraft_state.getPVCoordinates().getPosition() gP = self.earth.transform(self.satPos_i, self.in_frame, self.in_date) topoframe = TopocentricFrame(self.earth, gP, 'ENU') topo2inertial = topoframe.getTransformTo(self.in_frame, self.in_date) lat = gP.getLatitude() lon = gP.getLongitude() alt = gP.getAltitude() / 1e3 # Mag. Field needs degrees and [km] # get B-field in geodetic system (X:East, Y:North, Z:Nadir) B_geo = FileDataHandler.mag_field_model.calculateField( degrees(lat), degrees(lon), alt).getFieldVector() # convert geodetic frame to inertial and from [nT] to [T] B_i = topo2inertial.transformVector(Vector3D(1e-9, B_geo)) B_b = self.inertial2Sat.applyTo(B_i) B_field = np.array([B_b.x, B_b.y, B_b.z]) self.dipoleM.initializeHysteresisModel(B_field) # add bar magnets to satellite for key, bar in model['BarMagnet'].items(): direction = np.array([float(x) for x in bar['dir'].split(" ")]) self.dipoleM.addBarMagnet(direction, bar['m'])
def _compute_magnetic_torque(self, curr_date): """Compute magnetic torque if magnetic model provided. This method converts the satellite's position into Longitude, Latitude, Altitude representation to determine the geo. magnetic field at that position and then computes based on those values the magnetic torque. Args: curr_date: Absolute date of current epoch Returns: Vector3D: magnetic torque at satellite position in satellite frame along principal axes """ if self._to_add[1]: gP = self.earth.transform(self.satPos_i, self.in_frame, curr_date) topoframe = TopocentricFrame(self.earth, gP, 'ENU') topo2inertial = topoframe.getTransformTo(self.in_frame, curr_date) lat = gP.getLatitude() lon = gP.getLongitude() alt = gP.getAltitude() / 1e3 # Mag. Field needs degrees and [km] # get B-field in geodetic system (X:East, Y:North, Z:Nadir) B_geo = FileDataHandler.mag_field_model.calculateField( degrees(lat), degrees(lon), alt).getFieldVector() # convert geodetic frame to inertial and from [nT] to [T] B_i = topo2inertial.transformVector(Vector3D(1e-9, B_geo)) B_b = self.inertial2Sat.applyTo(B_i) B_b = np.array([B_b.x, B_b.y, B_b.z]) dipoleVector = self.dipoleM.getDipoleVectors(B_b) torque = np.sum(np.cross(dipoleVector, B_b), axis=0) self._mTorque = Vector3D(float(torque[0]), float(torque[1]), float(torque[2])) else: self._mTorque = Vector3D.ZERO
def _calculate_magnetic_field(self, oDate): """Calculate the magnetic field at position of the spacecraft (Internal Method).""" space_state = self._propagator_num.getInitialState() satPos = space_state.getPVCoordinates().getPosition() inertial2Sat = space_state.getAttitude().getRotation() frame = space_state.getFrame() gP = self._earth.transform(satPos, frame, oDate) topoframe = TopocentricFrame(self._earth, gP, 'ENU') topo2inertial = topoframe.getTransformTo(frame, oDate) lat = gP.getLatitude() lon = gP.getLongitude() alt = gP.getAltitude() / 1e3 # Mag. Field needs degrees and [km] # get B-field in geodetic system (X:East, Y:North, Z:Nadir) B_geo = FileDataHandler.mag_field_model.calculateField( degrees(lat), degrees(lon), alt).getFieldVector() # convert geodetic frame to inertial and from [nT] to [T] B_i = topo2inertial.transformVector(Vector3D(1e-9, B_geo)) return inertial2Sat.applyTo(B_i)