Skip to content

Commit

Permalink
Put min and max wire resistivity into CCKCContants and implement in W…
Browse files Browse the repository at this point in the history
…ireResistivityControl range - see #928
  • Loading branch information
UniverseAndMore committed Jan 19, 2023
1 parent a50eaee commit 28623e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion js/CCKCConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const CCKCConstants = {
// R = rho * L / A. Resistance = resistivity * Length / cross sectional area.
// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity says copper has rho=1.68E-8 Ohm * m
// According to http://www.sengpielaudio.com/calculator-cross-section.htm AWG Wire Gauge of 20 has 0.52mm^2 = 5.2e-7m^2
DEFAULT_RESISTIVITY: CCKCQueryParameters.wireResistivity, // Ohm * m
MIN_WIRE_RESISTIVITY: CCKCQueryParameters.wireResistivity, // Ohm * m
MAX_WIRE_RESISTIVITY: 0.0168, // Ohm * m

WIRE_CROSS_SECTIONAL_AREA: 5E-4, // meters squared

Expand Down
6 changes: 4 additions & 2 deletions js/model/Circuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import NumberProperty from '../../../axon/js/NumberProperty.js';
import createObservableArray, { ObservableArray } from '../../../axon/js/createObservableArray.js';
import Property from '../../../axon/js/Property.js';
import dotRandom from '../../../dot/js/dotRandom.js';
import Range from '../../../dot/js/Range.js';
import Vector2 from '../../../dot/js/Vector2.js';
import PhetioGroup from '../../../tandem/js/PhetioGroup.js';
import NullableIO from '../../../tandem/js/types/NullableIO.js';
Expand Down Expand Up @@ -160,8 +161,9 @@ export default class Circuit {
this.includeACElements = options.includeACElements;
this.includeLabElements = options.includeLabElements;
this.blackBoxStudy = options.blackBoxStudy;
this.wireResistivityProperty = new NumberProperty( CCKCConstants.DEFAULT_RESISTIVITY, {
tandem: tandem.parentTandem!.createTandem( 'wireResistivityProperty' )
this.wireResistivityProperty = new NumberProperty( CCKCConstants.MIN_WIRE_RESISTIVITY, {
tandem: tandem.parentTandem!.createTandem( 'wireResistivityProperty' ),
range: new Range( CCKCConstants.MIN_WIRE_RESISTIVITY, CCKCConstants.MAX_WIRE_RESISTIVITY )
} );

this.sourceResistanceProperty = new NumberProperty( CCKCConstants.DEFAULT_BATTERY_RESISTANCE, {
Expand Down
9 changes: 3 additions & 6 deletions js/view/WireResistivityControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const wireResistivityStringProperty = CircuitConstructionKitCommonStrings.wireRe
// constants
const TICK_LABEL_TEXT_OPTIONS = { fontSize: 12, maxWidth: 45 };

// Chosen so that current through battery+long wire+long wire+resistor would match prior version, see https://github.com/phetsims/circuit-construction-kit-common/issues/553
const MAX_RESISTIVITY = 0.0168;

export default class WireResistivityControl extends VBox {

/**
Expand All @@ -39,8 +36,8 @@ export default class WireResistivityControl extends VBox {
const titleNode = new Text( wireResistivityStringProperty, titleConfig );

const slider = new HSlider( wireResistivityProperty, new Range(
CCKCConstants.DEFAULT_RESISTIVITY,
MAX_RESISTIVITY // large enough so that max resistance in a 9v battery slows to a good rate
CCKCConstants.MIN_WIRE_RESISTIVITY,
CCKCConstants.MAX_WIRE_RESISTIVITY // large enough so that max resistance in a 9v battery slows to a good rate
), {
trackSize: CCKCConstants.SLIDER_TRACK_SIZE,
thumbSize: CCKCConstants.THUMB_SIZE,
Expand All @@ -49,7 +46,7 @@ export default class WireResistivityControl extends VBox {
} );

slider.addMajorTick( 0, new Text( tinyStringProperty, TICK_LABEL_TEXT_OPTIONS ) );
slider.addMajorTick( MAX_RESISTIVITY, new Text( lotsStringProperty, TICK_LABEL_TEXT_OPTIONS ) );
slider.addMajorTick( CCKCConstants.MAX_WIRE_RESISTIVITY, new Text( lotsStringProperty, TICK_LABEL_TEXT_OPTIONS ) );

super( {
children: [ titleNode, slider ],
Expand Down

0 comments on commit 28623e5

Please sign in to comment.