Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from TsvetelinKostadinv/develop/Tsvetelin
Browse files Browse the repository at this point in the history
GUI update
  • Loading branch information
TsvetelinKostadinv authored Mar 23, 2020
2 parents 2936e98 + b36697e commit 401d2c2
Show file tree
Hide file tree
Showing 18 changed files with 777 additions and 86 deletions.
16 changes: 0 additions & 16 deletions .classpath

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/bin
/test_results
/.settings

.project
.classpath

# Ignore Gradle project-specific cache directory
.gradle
gradle.properties

# Ignore Gradle build output directory
/build
17 changes: 0 additions & 17 deletions .project

This file was deleted.

36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# Simulation-Q
[![Build Status](https://travis-ci.org/TsvetelinKostadinv/Simulation-Q.svg?branch=master)](https://travis-ci.org/TsvetelinKostadinv/Simulation-Q)
A simulation of the inner working of a quantum computer

**General info about current state**

Travis CI: [![Build Status](https://travis-ci.org/TsvetelinKostadinv/Simulation-Q.svg?branch=master)](https://travis-ci.org/TsvetelinKostadinv/Simulation-Q)

## Goals
Simulation-Q is designed to model quantum phenomena in a stable package both for home and research use.
The simulation should be fast enough so it can compete with a real quantum computer.

## Contribution
Everyone eager enough and excited about this project is free to fork it and work or even contact me([here]([email protected] ))


## Implementation details
It started off as a Java project solely because I am most familiar with it. However, it may be ported to a lower level lang one day...


## How to test it yourself
This section is likely to change a lot so I am putting it at the bottom.
As of [this commit](https://github.com/TsvetelinKostadinv/Simulation-Q/tree/a5455c2a274b49c0c6c0440cc4c245737e4f0782 "this commit") the project is yet to have a GUI( or a proper CLI for that matter ). Fear not, I am working on it... It will be done, eventually.
So, back on track.
First you have to clone the project, wither way you prefer, you need it on your local machine.
Next to run the project you just need to open command prompt in the main directory and type:
```
gradlew clean build run
```
or
```
./gradlew clean build run
```
on Unix based systems
This will construct a sample quantum register and apply sample transformations( nothing if I recall correctly ), and collapses it a million times and performs a poor microbenchmark saying how long it took.
However, if you want to tinker with it you can navigate to the file named Presenting.java
At the top you will find constants with explanatory comments so that you can change them up and experiment.
52 changes: 16 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ plugins {

// Apply the application plugin to add support for building a CLI application.
id 'application'

// The JavaFX plugin
id 'org.openjfx.javafxplugin' version '0.0.8'

// The eclipse otherwise it will emmit errors
id 'eclipse'
}

version = '1.2.0.0'
Expand All @@ -31,44 +37,18 @@ test{
useJUnitPlatform()
}

application {
mainClassName ''
}


//this increments the version number up there
ext.assembleNextVersionNumber = { oldVersion ->

def parts = oldVersion.tokenize(".")
int buildCode = parts[parts.size()-1] as Integer

buildCode+=1

return parts[0] + '.' + parts[1] + '.' + parts[2] + '.' + buildCode
javafx {
version = "13"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}

task patch{
def parts = version.tokenize(".")
int patchCode = parts[2] as Integer

patchCode+=1

return parts[0] + '.' + parts[1] + '.' + patchCode + '.' + parts[3]
run {
if (javafx.platform.classifier == 'win') {
// Temporal fix for Eclipse with JDK 1.8 and Windows
systemProperty "java.library.path", "C:\tmp"
}
}

task minor{
def parts = version.tokenize(".")
int minorCode = parts[1] as Integer

minorCode+=1

return parts[0] + '.' + minorCode + '.' + parts[2] + '.' + parts[3]
}

//this replaces the version up there with the one here
task incrementVersion{
String newVersion = assembleNextVersionNumber(version)
def s = buildFile.getText().replaceFirst("version = '$version'", "version = '" + newVersion + "'")
buildFile.setText(s)
application {
mainClassName 'com.gui.GUIStarter'
}

53 changes: 53 additions & 0 deletions src/main/java/com/gui/CollapseDataModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 20/03/2020 13:17:14
* QCollapserModel.java created by Tsvetelin
*/
package com.gui;


import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.simulationQ.simulation.computation.QCollapser;
import com.simulationQ.simulation.computation.QFinalStateCalculator;
import com.simulationQ.simulation.computation.program.QProgram;
import com.simulationQ.simulation.computation.qubits.register.CRegister;
import com.simulationQ.simulation.computation.qubits.register.QRegister;


/**
* @author Tsvetelin
*
*/
public interface CollapseDataModel
{

// TODO this should take in a Register and a program which will be
// constructed in the controller
static Map< String , Number > generateCollapseData ( final CRegister starting ,
final QProgram program ,
final int count )
{
final Map< String , Number > res = new LinkedHashMap<>();
if ( starting.size() == 0 ) return res;

final QRegister finalState = QFinalStateCalculator.calculateFinalState( program ,
starting );

final List< String > results = QCollapser.generateCollapseData( finalState ,
count );

for ( String possibility : QCollapser.generateBinaryStringValues( starting.size() ) )
{
res.put( possibility , 0 );
}

for ( String state : results )
{
// res.put( state , res.get( state ).intValue() + 1 );
res.compute( state , (str, n) -> n.intValue()+1 );
}

return res;
}
}
53 changes: 53 additions & 0 deletions src/main/java/com/gui/GUIStarter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 21/03/2020 14:44:20
* GUIStarter.java created by Tsvetelin
*/
package com.gui;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

/**
* @author Tsvetelin
*
*/
public class GUIStarter extends Application implements Runnable
{

public static final String FXML_FILE_LOCATION = "main_window.fxml";
public static final String CSS_FILE_LOCATION = "styles.css";
public static final String ICON_FILE_LOCATION = "logo.png";

public static final String TITLE = "Simulation-Q";

@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource(FXML_FILE_LOCATION));

Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource(CSS_FILE_LOCATION).toExternalForm());

stage.setTitle(TITLE);
stage.getIcons().add(new Image( getClass().getResourceAsStream(ICON_FILE_LOCATION) ));
stage.setScene(scene);
stage.show();
}

@Override
public void run() {
System.out.println( "Starting..." );
GUIStarter.launch(new String[0]);
}

public static void main ( String [] args )
{
GUIStarter s = new GUIStarter();

s.run();
}

}
Loading

0 comments on commit 401d2c2

Please sign in to comment.