Skip to content

Instantly share code, notes, and snippets.

@songyang-dev
Last active April 17, 2023 17:15

Revisions

  1. songyang-dev revised this gist Apr 17, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions IdealGasConstant.java
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,8 @@ public class IdealGasConstant {
    private static IdealGasConstant _instance = new IdealGasConstant();

    private IdealGasConstant() {
    _instance.litersAtmospherePerKelvinPerMole = 0.082057366080960;
    _instance.metersCubedPascalPerKelvinPerMole = 8.31446261815324;
    this.litersAtmospherePerKelvinPerMole = 0.082057366080960;
    this.metersCubedPascalPerKelvinPerMole = 8.31446261815324;
    }

    public static IdealGasConstant getInstance() {
  2. songyang-dev revised this gist Apr 17, 2023. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions IdealGasConstant.java
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,9 @@ public class IdealGasConstant {

    public double metersCubedPascalPerKelvinPerMole; //m3⋅Pa⋅K−1⋅mol−1

    private static IdealGasConstant _instance;
    private static IdealGasConstant _instance = new IdealGasConstant();

    private IdealGasConstant() {
    _instance = new IdealGasConstant();
    _instance.litersAtmospherePerKelvinPerMole = 0.082057366080960;
    _instance.metersCubedPascalPerKelvinPerMole = 8.31446261815324;
    }
  3. songyang-dev created this gist Apr 17, 2023.
    24 changes: 24 additions & 0 deletions Acceleration.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    class Acceleration {

    public double metersPerSecondSquared;

    public double kilometersPerSecondSquared;

    public double newtonsPerKilogram;

    public Acceleration(double metersPerSecondSquared) {
    this.metersPerSecondSquared = metersPerSecondSquared;
    this.kilometersPerSecondSquared = metersPerSecondSquared / 1000;
    this.newtonsPerKilogram = metersPerSecondSquared;
    }


    public static void main(String[] args) {

    Acceleration accelerationEarth = new Acceleration(9.8);

    double timeSeconds = 10.0;
    double distanceMeters = accelerationEarth.metersPerSecondSquared * timeSeconds * timeSeconds;

    }
    }
    16 changes: 16 additions & 0 deletions GravityConstants.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    public class GravityConstants {

    public static final Acceleration EARTH = new Acceleration(9.8);

    public static final Acceleration MOON = new Acceleration(1.6);

    public static final Acceleration SUN = new Acceleration(275);

    public static void main(String[] args) {


    // F = m g
    double massBallKilogram = 1.0;
    var earthGravityNewtons = massBallKilogram * GravityConstants.EARTH.newtonsPerKilogram;
    }
    }
    30 changes: 30 additions & 0 deletions IdealGasConstant.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    public class IdealGasConstant {

    public double litersAtmospherePerKelvinPerMole; // L⋅atm⋅K−1⋅mol−1

    public double metersCubedPascalPerKelvinPerMole; //m3⋅Pa⋅K−1⋅mol−1

    private static IdealGasConstant _instance;

    private IdealGasConstant() {
    _instance = new IdealGasConstant();
    _instance.litersAtmospherePerKelvinPerMole = 0.082057366080960;
    _instance.metersCubedPascalPerKelvinPerMole = 8.31446261815324;
    }

    public static IdealGasConstant getInstance() {
    return _instance;
    }

    public static void main(String[] args) {
    IdealGasConstant idealGasConstant = IdealGasConstant.getInstance();

    // P V = n R T

    double numberOfParticlesMole = 1;
    double temperatureKelvin = 273;
    double pressurePascal = 100;
    double volumeMetersCubed = numberOfParticlesMole * idealGasConstant.metersCubedPascalPerKelvinPerMole * temperatureKelvin / pressurePascal;
    }

    }