Skip to content

Commit

Permalink
rename ParticleNucleus -> ShellModelNucleus, #183
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Aug 30, 2023
1 parent 515b321 commit a8f8c25
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions doc/implementation-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ counter all depend on these count properties.

- __ParticleAtom__: A way of representing an atom in the model. It contains and manages references to constituent
particles.
- __ParticleNucleus__: A subtype of ParticleAtom. This manages the positions and motion of all particles in the nucleus
- __ShellModelNucleus__: A subtype of ParticleAtom. This manages the positions and motion of all particles in the nucleus
on the Chart Intro screen.
- __ParticleAtomNode__: Node that holds the ParticleView's from ParticleAtom. Rearranges particles in different node
layers
Expand Down Expand Up @@ -47,10 +47,10 @@ is not considered as a part of the ParticleAtom particles.
the ParticleAtom particles.
- __protonShellPositions__: Array to keep track of where a proton particle can be placed in the energy levels. This
array
exists only in the ParticleNucleus.
exists only in the ShellModelNucleus.
- __neutronShellPositions__: Array to keep track of where a neutron particle can be placed in the energy levels. This
array
exists only in the ParticleNucleus.
exists only in the ShellModelNucleus.

The ParticleView's of the model particles are kept track of in the `particleViewMap`, a lookup map which uses the
particle's id as a key. All ParticleView's are stored in the map, including the mini-atom ParticleView's.
Expand Down Expand Up @@ -88,7 +88,7 @@ on the decay type, can create or remove particles. Note, the beta decay type is
nucleon type of a nucleon particle.

It's important to note that in the Chart Intro screen, an _incoming_ particle holds a position in the _ShellPositions_
before it reaches its destination to become a part of the ParticleNucleus' particles.
before it reaches its destination to become a part of the ShellModelNucleus' particles.

#### ModelViewTransform's

Expand Down
20 changes: 10 additions & 10 deletions js/chart-intro/model/ChartIntroModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import buildANucleus from '../../buildANucleus.js';
import BANModel from '../../common/model/BANModel.js';
import ParticleNucleus from './ParticleNucleus.js';
import ShellModelNucleus from './ShellModelNucleus.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import ParticleType from '../../common/model/ParticleType.js';
import Particle from '../../../../shred/js/model/Particle.js';
Expand All @@ -22,10 +22,10 @@ import BANParticle from '../../common/model/BANParticle.js';
// types
export type SelectedChartType = 'partial' | 'zoom';

class ChartIntroModel extends BANModel<ParticleNucleus> {
class ChartIntroModel extends BANModel<ShellModelNucleus> {

// The atom that the user builds, modifies, and generally plays with.
public readonly particleNucleus: ParticleNucleus;
public readonly shellModelNucleus: ShellModelNucleus;

// The non-interactive mini-nucleus at the top of the screen.
public readonly miniParticleAtom: ParticleAtom;
Expand All @@ -42,21 +42,21 @@ class ChartIntroModel extends BANModel<ParticleNucleus> {

public constructor() {

const particleAtom = new ParticleNucleus(); // This is our ground truth 'atom'.
const particleAtom = new ShellModelNucleus(); // This is our ground truth 'atom'.

// Empirically determined, the last nuclide the NuclideChartIntro screen goes up to is Neon-22 (10 protons
// and 12 neutrons).
super( BANConstants.CHART_MAX_NUMBER_OF_PROTONS, BANConstants.CHART_MAX_NUMBER_OF_NEUTRONS, particleAtom );

this.particleNucleus = particleAtom;
this.shellModelNucleus = particleAtom;

// This is the mini-nucleus that updates based on the particleAtom.
this.miniParticleAtom = new ParticleAtom();

this.selectedNuclideChartProperty = new Property<SelectedChartType>( 'partial' );

this.decayEquationModel = new DecayEquationModel( ChartIntroModel.cellModelArray,
this.particleNucleus.protonCountProperty, this.particleNucleus.massNumberProperty );
this.shellModelNucleus.protonCountProperty, this.shellModelNucleus.massNumberProperty );
}

/**
Expand All @@ -69,18 +69,18 @@ class ChartIntroModel extends BANModel<ParticleNucleus> {
}

/**
* Remove the particle from its shell position in the ParticleNucleus.
* Remove the particle from its shell position in the ShellModelNucleus.
*/
public override removeParticle( particle: Particle ): void {
this.particleNucleus.removeParticleFromShell( particle );
this.shellModelNucleus.removeParticleFromShell( particle );
super.removeParticle( particle );
}

/**
* Select the particle in the farthest energy level.
*/
public override getParticleToReturn( particleType: ParticleType, creatorNodePosition: Vector2 ): Particle {
const particleToReturn = this.particleNucleus.getLastParticleInShell( particleType );
const particleToReturn = this.shellModelNucleus.getLastParticleInShell( particleType );
assert && assert( particleToReturn, 'No particle of type ' + particleType.name + ' exists in the particleAtom.' );
assert && assert( !particleToReturn!.isDisposed, 'Particle should not already be disposed.' );

Expand All @@ -92,7 +92,7 @@ class ChartIntroModel extends BANModel<ParticleNucleus> {
* Return the next open shell position for the given particleType and add it to that shell position.
*/
public override getParticleDestination( particleType: ParticleType, particle: Particle ): Vector2 {
return this.particleNucleus.getParticleDestination( particleType, particle );
return this.shellModelNucleus.getParticleDestination( particleType, particle );
}

public override reset(): void {
Expand Down
2 changes: 1 addition & 1 deletion js/chart-intro/model/EnergyLevelType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EnergyLevelType extends EnumerationValue {
[ EnergyLevelType.N_ZERO, EnergyLevelType.N_ONE, EnergyLevelType.N_TWO ] as const;

/**
* Given a particle index (0-based), return the EnergyLevelType that it will be placed on. See ParticleNucleus.
* Given a particle index (0-based), return the EnergyLevelType that it will be placed on. See ShellModelNucleus.
*/
public static getForIndex( index: number ): EnergyLevelType {
let indexRemainder = index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const PARTICLE_Y_SPACING = PARTICLE_DIAMETER * 4;
// Have one less space than there are particles.
const NUMBER_OF_RADII_SPACES_BETWEEN_PARTICLES = N_ONE_CAPACITY - 1;

// This transform maps from arbitrary particle positions in the ParticleNucleus (see ALLOWED_PARTICLE_POSITIONS) to
// This transform maps from arbitrary particle positions in the ShellModelNucleus (see ALLOWED_PARTICLE_POSITIONS) to
// actual model/view positions to be rendered. This is private because model units in this sim are the same as
// view units, and this is just for ease of this class's implementation.
const PARTICLE_POSITIONING_TRANSFORM = ModelViewTransform2.createRectangleInvertedYMapping(
Expand All @@ -66,7 +66,7 @@ for ( let i = 0; i < EnergyLevelType.ENERGY_LEVELS.length; i++ ) {
assert && assert( ALLOWED_PARTICLE_POSITIONS[ i ].length === energyLevel.capacity, `n${i} capacity spots check` );
}

class ParticleNucleus extends ParticleAtom {
class ShellModelNucleus extends ParticleAtom {

// Allowed proton positions.
public readonly protonShellPositions: ParticleShellPosition[][] = [ [], [], [] ];
Expand Down Expand Up @@ -200,7 +200,7 @@ class ParticleNucleus extends ParticleAtom {
/**
* Remove the particle's placement in the shell and from the ParticleAtom.
* We need to remove from the shell here too since sometimes a particle is not a part of the ParticleAtom, but it does
* have a shell position here in the ParticleNucleus.
* have a shell position here in the ShellModelNucleus.
*/
public override removeParticle( particle: Particle ): void {
this.removeParticleFromShell( particle );
Expand Down Expand Up @@ -324,5 +324,5 @@ class ParticleNucleus extends ParticleAtom {
}
}

buildANucleus.register( 'ParticleNucleus', ParticleNucleus );
export default ParticleNucleus;
buildANucleus.register( 'ShellModelNucleus', ShellModelNucleus );
export default ShellModelNucleus;
10 changes: 5 additions & 5 deletions js/chart-intro/view/ChartIntroScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {
private readonly neutronEnergyLevelNode: NucleonShellView;
private readonly energyLevelLayer = new Node();

// If the miniAtom is connected to the main particleAtom (ParticleNucleus in the Chart Intro screen). When true the
// If the miniAtom is connected to the main particleAtom (ShellModelNucleus in the Chart Intro screen). When true the
// mini ParticleAtom is kept in sync (false only for when decaying particles cause behavior differences in each
// representation).
private isMiniAtomConnected = true;
Expand Down Expand Up @@ -92,7 +92,7 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {
// Add nucleons to miniAtom.
if ( nucleonDelta < 0 ) {

// If true, keep the mini atom's particles identical to those in the ParticleNucleus.
// If true, keep the mini atom's particles identical to those in the ShellModelNucleus.
if ( this.isMiniAtomConnected ) {
_.times( nucleonDelta * -1, () => {
const miniParticle = model.createMiniParticleModel( particleType );
Expand All @@ -105,7 +105,7 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {
else if ( nucleonDelta > 0 ) {
_.times( nucleonDelta, () => {

// If true, keep the mini atom's particles identical to those in the ParticleNucleus.
// If true, keep the mini atom's particles identical to those in the ShellModelNucleus.
if ( this.isMiniAtomConnected ) {
const particle = model.miniParticleAtom.extractParticle( particleType.particleTypeString );
particle.dispose();
Expand Down Expand Up @@ -304,7 +304,7 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {
super.emitNucleon( particleType, this.model.miniParticleAtom );
this.model.miniParticleAtom.reconfigureNucleus();

// Fade away the nucleon in the ParticleNucleus.
// Fade away the nucleon in the ShellModelNucleus.
this.fadeOutShellNucleon( particleType );

this.isMiniAtomConnected = true;
Expand All @@ -314,7 +314,7 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {
* Fade away and remove a nucleon of a given particleType from the energy levels.
*/
private fadeOutShellNucleon( particleType: ParticleType ): void {
const shellNucleusNucleon = this.model.particleNucleus.extractParticle( particleType.particleTypeString );
const shellNucleusNucleon = this.model.shellModelNucleus.extractParticle( particleType.particleTypeString );
this.model.outgoingParticles.add( shellNucleusNucleon );
const particleView = this.findParticleView( shellNucleusNucleon );
particleView.inputEnabled = false;
Expand Down
2 changes: 1 addition & 1 deletion js/chart-intro/view/NucleonShellView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import ParticleType from '../../common/model/ParticleType.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import { N_ZERO_CAPACITY, ParticleShellPosition, N_ONE_CAPACITY } from '../model/ParticleNucleus.js';
import { N_ZERO_CAPACITY, ParticleShellPosition, N_ONE_CAPACITY } from '../model/ShellModelNucleus.js';
import EnergyLevelType from '../model/EnergyLevelType.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';

Expand Down
2 changes: 1 addition & 1 deletion js/chart-intro/view/NuclideChartNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import ChartIntroModel from '../model/ChartIntroModel.js';
import NuclideChartCellModel from '../model/NuclideChartCellModel.js';
import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import BANColors from '../../common/BANColors.js';
import { N_ONE_CAPACITY, N_ZERO_CAPACITY } from '../model/ParticleNucleus.js';
import { N_ONE_CAPACITY, N_ZERO_CAPACITY } from '../model/ShellModelNucleus.js';
import AlphaParticle from '../../common/model/AlphaParticle.js';
import BANModel from '../../common/model/BANModel.js';

Expand Down
4 changes: 2 additions & 2 deletions js/common/view/BANScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransfo
import ParticleType from '../model/ParticleType.js';
import ParticleAtom from '../../../../shred/js/model/ParticleAtom.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import ParticleNucleus from '../../chart-intro/model/ParticleNucleus.js';
import ShellModelNucleus from '../../chart-intro/model/ShellModelNucleus.js';
import ParticleAtomNode from './ParticleAtomNode.js';
import DecayType from '../model/DecayType.js';
import dotRandom from '../../../../dot/js/dotRandom.js';
Expand All @@ -48,7 +48,7 @@ type ParticleTypeInfo = {
outgoingNucleons: number;
};

abstract class BANScreenView<M extends BANModel<ParticleAtom | ParticleNucleus>> extends ScreenView {
abstract class BANScreenView<M extends BANModel<ParticleAtom | ShellModelNucleus>> extends ScreenView {

protected model: M;
private previousProtonNumber = 0;
Expand Down
6 changes: 3 additions & 3 deletions js/common/view/NucleonCreatorsNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import DoubleArrowButton, { ArrowButtonDirection } from './DoubleArrowButton.js'
import merge from '../../../../phet-core/js/merge.js';
import BANColors from '../BANColors.js';
import BANModel from '../model/BANModel.js';
import ParticleNucleus from '../../chart-intro/model/ParticleNucleus.js';
import ShellModelNucleus from '../../chart-intro/model/ShellModelNucleus.js';
import ParticleAtom from '../../../../shred/js/model/ParticleAtom.js';
import ArrowButton from '../../../../sun/js/buttons/ArrowButton.js';
import Particle from '../../../../shred/js/model/Particle.js';
Expand Down Expand Up @@ -61,14 +61,14 @@ class NucleonCreatorsNode extends HBox {
private readonly neutronNumberRange: Range;
private readonly createParticleFromStack: ( particleType: ParticleType ) => Particle;
private readonly returnParticleToStack: ( particleType: ParticleType ) => void;
private model: BANModel<ParticleAtom | ParticleNucleus>;
private model: BANModel<ParticleAtom | ShellModelNucleus>;
private readonly particleTransform: ModelViewTransform2;

// The NucleonCreatorNode for the protons and neutrons.
public readonly protonsCreatorNode: Node;
public readonly neutronsCreatorNode: Node;

public constructor( model: BANModel<ParticleAtom | ParticleNucleus>,
public constructor( model: BANModel<ParticleAtom | ShellModelNucleus>,
addAndDragParticle: ( event: PressListenerEvent, particle: Particle ) => void,
particleTransform: ModelViewTransform2,
createParticleFromStack: ( particleType: ParticleType ) => Particle,
Expand Down

0 comments on commit a8f8c25

Please sign in to comment.